logo

String IndexOf(int Ch, Int FromIndex)


Show

Description

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.

Syntax

Here is the syntax of this method:

public in indexOf(char ch, int fromIndex)

Parameters

Here is the detail of parameters −

  • ch − a character.
  • fromIndex − the index to start the search from.

Return Value

  • See the description.

Example

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:

Output

Found Index :9

Here at Intellinuts, we have created a complete Java tutorial for Beginners to get started in Java.