Hi,
For searching for a particular character from a string and getting the index of that particular character, use the following code.
public class MainClass{ public static void main(String[] arg){ String myStr = "Coderz"; int strIndex = 0; strIndex = myStr.indexOf('o'); System.out.println(strIndex); } }
It will print out the index of ‘o’, that’s 1.
🙂