Here you can find the source of lastIndexOf(String pattern, String s)
public static int lastIndexOf(String pattern, String s)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { public static final String EMPTY_STRING = ""; public static int lastIndexOf(String pattern, String s) { if (!isNullOrEmpty(s)) { int pos = s.indexOf(pattern); while (pos != -1) { if ((pos + 1) >= s.length()) return pos; int newPos = s.substring(pos + 1).indexOf(pattern); if (newPos > 0) { pos = newPos + 1 + pos; } else { return pos; }// ww w . j a va 2 s.c o m } } return -1; } public static boolean isNullOrEmpty(String[] s) { if ((s == null) || (s.length == 0)) return true; for (int i = 0; i < s.length; i++) { if (!isNullOrEmpty(s[i])) { return false; } } return true; } public static boolean isNullOrEmpty(List<String> input) { return (input == null) ? true : isNullOrEmpty(input.toArray(new String[input.size()])); } public static boolean isNullOrEmpty(String s) { return (s == null) || s.equals(EMPTY_STRING); } }