Check out example codes for "java string indexof". It will help you in understanding the concepts better.

Code Example 1

  // Initialising String 
        String gfg = new String("Welcome to geeksforgeeks"); 
  
        System.out.print("Found g first at position : "); 
  
        // Initial index of 'g' will print 
        // prints 11 
        System.out.println(gfg.indexOf('g'));

Code Example 2

public class MyClass {
  public static void main(String[] args) {
    String myStr = "Hello planet earth, you are a great planet.";
    System.out.println(myStr.indexOf("planet"));
  }
}

Learn ReactJs, React Native from akashmittal.com