Here you can find the source of lastIndexOf(List
public static int lastIndexOf(List<String> lines, String... conditions)
//package com.java2s; import java.util.List; public class Main { public static int lastIndexOf(List<String> lines, String... conditions) { for (int i = lines.size() - 1; i >= 0; i--) { String line = lines.get(i); if (matchLine(line, conditions)) return i; }/*from www.j a v a 2 s . co m*/ return -1; } private static boolean matchLine(String line, String[] conditions) { for (String condition : conditions) { boolean exclude = false; if (condition.startsWith("\\")) { exclude = true; condition = condition.substring(1); } if (exclude && line.contains(condition)) return false; if (!exclude && !line.contains(condition)) return false; } return true; } }