// 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'));