Evans Vera
2
Q:

indexof in java

The java string indexOf() method returns index of given character value or substring. If it is not found, it returns -1. The index counter starts from zero.
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')); 
3

New to Communities?

Join the community