Java String indexOf(String str,int fromIndex)Example
String class indexOf(String str,int fromIndex)method example
String class indexOf(String str, int fromIndex) method example. This example shows you how to use indexOf(String str, int fromIndex)method.This method Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
Here is the code:-
/**
* @(#) IndexofString3string.java
*Program that Returns the index within the string of the first occurrence of the specified substring, starting at the specified index.
* @Version 02-May-2008
* @author Rose India Team
*/
public class IndexofString3string
{
public static void main(String args[])
{
// Declaration of String
String s = "Welcome to Rose india Rose";
//Displaying the given String definrd above
System.out.println(s);
//Returns the index within this string of the first occurrence of the specified substring, starting at the specified index.
System.out.println("INDEX OF 'Rose' IN THE STRING IS=" + s.indexOf("Rose",12) );
}
} |
null
|