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






public class MainClass{

  public static void main(String[] arg){
    String str = "abcde";
    
    int index = 0;        
    index = str.indexOf('c');  

    System.out.println(index);
  }

}
2








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