Java tutorial
public class Main { public static void main(String[] args) { String str = new String("Apple"); int index = str.indexOf('p'); // index will have a value of 1 System.out.println(index); index = str.indexOf("pl"); // index will have a value of 2 System.out.println(index); index = str.lastIndexOf('p'); // index will have a value of 2 System.out.println(index); index = str.lastIndexOf("pl"); // index will have a value of 2 System.out.println(index); index = str.indexOf("k"); // index will have a value of -1 System.out.println(index); } }