Here you can find the source of isSubList(List
public static <T> boolean isSubList(List<T> l1, List<? super T> l)
//package com.java2s; import java.util.*; public class Main { /**/*w ww .ja va2s. c om*/ * Returns true iff l1 is a sublist of l (i.e., every member of l1 is in l, * and for every e1 < e2 in l1, there is an e1 < e2 occurrence in l). */ public static <T> boolean isSubList(List<T> l1, List<? super T> l) { Iterator<? super T> it = l.iterator(); for (T o1 : l1) { if (!it.hasNext()) { return false; } Object o = it.next(); while ((o == null && !(o1 == null)) || (o != null && !o.equals(o1))) { if (!it.hasNext()) { return false; } o = it.next(); } } return true; } }