Java tutorial
public class Main { public static void main(String[] args) { String strOrig = "A B C A"; int intIndex = strOrig.indexOf("B"); if (intIndex == -1) { System.out.println("not found"); } else { System.out.println("Found " + intIndex); } int positionIndex = strOrig.indexOf("A", 2); System.out.println("after 2 is " + positionIndex); int lastIndex = strOrig.lastIndexOf("A"); System.out.println("Last index " + lastIndex); } } /* Found 2 after 2 is 6 Last index 6 */