Search for Last occurrence of a character in Java
Description
The following code shows how to search for Last occurrence of a character.
Example
//from w w w . j a v a 2 s .co m
public class Main {
public static void main(String[] argv) throws Exception {
String string = "this is a test from java2s.com";
int index = string.lastIndexOf('a');
System.out.println(index);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »