//javac String_Class_Methods.java
public class String_Class_Methods {
public static void main(String[] args) {
// TODO Auto-generated method stub
String str1 = new String("Hello World"); String str2 = "This is Java"; String space = " ";
String str3 ="this is\u0904 alright";
int n1 = str2.length(), n2 = str2.indexOf(space), n3 = str3.length();

System.out.println("str1 \t="+ str1 +" and it's length " + n1);
System.out.println("str2 \t="+ str2);
System.out.println("str3 \t="+ str3 +" and it's length " + n3);
System.out.println("----------------");
System.out.println(" str1.charAt(0)\t\t\t"+str1.charAt(0));
System.out.println(" str1.codePointAt(0))\t\t"+str1.codePointAt(0));
System.out.println(" str1.codePointBefore(1))\t"+str1.codePointBefore(1));
System.out.println("---This codePointCount() is new in Java 5.0 to handle unicode---");
System.out.println(" str3.codePointCount(0, n3))\t"+str3.codePointCount(0, (n3-2)));
System.out.println(" str1.compareTo('hello world'))\t"+str1.compareTo("hello world"));
System.out.println(" str1.compareToIgnoreCase('hello world'))\t"+str1.compareToIgnoreCase("hello world"));
System.out.println(" str1.concat('Very Good'))\t"+str1.concat(" Very Good"));
System.out.println("----------------");
System.out.println("str1.equals(str1)\t"+str1.equals(str1));
System.out.println("str1.equals(str2)\t"+str1.equals(str2));
System.out.println(" str1.hasCode())\t"+str1.hashCode());
System.out.println(" str1.indexOf(W))\t"+str1.indexOf("W"));
System.out.println(" Below is the use of str2.indexOf(string,string.length())");
System.out.println(" Searching space in \t= "+ str2);
while(n2>0)
{
System.out.println(" --while loop finds space at : " + n2 );
n2 = str2.indexOf(space, n2 + 1);
}
System.out.println(" Searching space char in str2.indexOf (ch, int) \t= "+ str2.indexOf(space, 0));
System.out.println("----------------- " );
System.out.println(" str3 = "+ str3 +" and it's length " + n3);
System.out.println(" str3.lastIndexOf(\"r\") char \t\t at " + str3.lastIndexOf("r") );
System.out.println(" str3.lastIndexOf(\"alright\") string \t at " + str3.lastIndexOf("alright"));
System.out.println(" str3.offsetByCodePoints(0, 9)\t"+ str3.charAt(str3.offsetByCodePoints(0, 9)));
System.out.println(" str3.offsetByCodePoints(0, 11)\t"+ str3.charAt(str3.offsetByCodePoints(0,11)));
//System.out.println(" str3.offsetByCodePoints(0, 11)\t"+ str3.replace(str3, replacement));

}

}