In this article, we will see how to use indexOf method of String class in Java.
In Java, Strings, we can use indexOf method to find position of a char acte within a text.
Lets look to our code.
String x = "abc";
System.out.println(x.indexOf("b"));
Lets see it in an example.
In above example, we created two String object. We assigned "andromeda" value to "t1", and added an another String to it with using "+" operator. We used indeOf method to find position of "n" letter in "andromeda" string .