xxxxxxxxxx
String txt = "Please locate where 'locate' occurs!";
System.out.println(txt.indexOf("locate")); // Outputs 7
xxxxxxxxxx
String str = "testdemo";
System.out.println("String: "+str);
int index = str.indexOf( 'h' );
System.out.printf("'h' is at index %d\n", index);