indexOf(int ch, int fromIndex) is a String process in Java and it is adopted to obtain the index of a particular value in the string from provided fromIndex. That depicts to search for the value will begin from the given index (fromIndex). This process returns the index within this string of the initial rate of the specified character, begin the search at the specified index or -1, if the character does not arise.
Here is the syntax of this method:
public in indexOf(char ch, int fromIndex)
Here is the detail of parameters −
import java.io.*; public class Test { public static void main(String args[]) { String Str = new String("Welcome to Intellinuts.com"); System.out.print("Found Index :" ); System.out.println(Str.indexOf( 'o', 5 )); } }
This will produce the following result:
Found Index :9
Here at Intellinuts, we have created a complete Java tutorial for Beginners to get started in Java.