Here you can find the source of containsInOrder(List
public static <T> boolean containsInOrder(List<T> a, List<T> b)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { public static <T> boolean containsInOrder(List<T> a, List<T> b) { int lastMatch = -1; for (int i = 0; i < b.size(); i++) { T find = b.get(i);/* ww w . j a v a2 s.co m*/ boolean found = false; for (int k = lastMatch + 1; k < a.size(); k++) { if (a.get(k).equals(find)) { lastMatch = k; found = true; break; } } if (!found) { return false; } } return true; } }