Searching for Substrings : Extracting String Characters « Data Type « Java Tutorial






public class MainClass{

  public static void main(String[] arg){
    String str = "abcdeabcdef";
    int startIndex = 3;
    
    int index = 0;        
    index = str.indexOf("ab", startIndex);         

    System.out.println(index);
  }

}
5








2.25.Extracting String Characters
2.25.1.Searching Strings for Characters
2.25.2.Finding the last occurrence of 'a' in the String variable text: the method lastIndexOf()
2.25.3.To search forwards from a given position: startIndex
2.25.4.Searching for Substrings
2.25.5.Last index of
2.25.6.Up to the end of the string
2.25.7.Beyond the last character of the substring
2.25.8.String Characters