Here you can find the source of lastIndexOf(CharSequence theChars, CharSequence theSearch)
public static int lastIndexOf(CharSequence theChars, CharSequence theSearch)
//package com.java2s; public class Main { /**/*from w ww. ja v a2 s . c o m*/ * Returns the last index of given search chars in given chars. */ public static int lastIndexOf(CharSequence theChars, CharSequence theSearch) { int cpos = theChars.length() - theSearch.length() + 1; char fchar = theSearch.charAt(0); while (--cpos >= 0) { if (theChars.charAt(cpos) == fchar) { int i = 0; for (i = 0; i < theSearch.length(); i++) if (theChars.charAt(cpos + i) != theSearch.charAt(i)) break; if (i == theSearch.length()) return cpos; } } return -1; } /** * Returns the length of given string (supports null). */ public static int length(CharSequence aString) { return aString == null ? 0 : aString.length(); } }