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