Java String search character from end
public class Main { public static void main(String[] args) { String letters = "abcdefghijklmabcdefghijklm"; // test lastIndexOf to find a character in a string System.out.printf("Last 'c' is located at index %d\n", letters.lastIndexOf('c')); int fromPosition = 25; System.out.printf("Last 'a' is located at index %d\n", letters.lastIndexOf('a', fromPosition)); System.out.printf("Last '$' is located at index %d\n\n", letters.lastIndexOf('$')); }// w ww .j a va 2s. c o m }