Here you can find the source of containsElement( List> list, List
public static <E extends Object> boolean containsElement( List<List<E>> list, List<E> element)
//package com.java2s; //License from project: LGPL import java.util.ArrayList; import java.util.Collection; import java.util.List; public class Main { public static <E extends Object> boolean containsElement( List<List<E>> list, List<E> element) { boolean found = false; for (List<E> e : list) { if (isEqual(element, e)) { found = true;//from w w w . j a v a 2 s. c om break; } } return found; } public static <E extends Object> boolean isEqual(List<E> from, List<E> to) { return (getCommonElements(from, to).size() == from.size()) && (from.size() == to.size()); } public static <E extends Object> List<E> getCommonElements( List<E> from, List<E> to) { List<E> res = new ArrayList<E>(); for (int i = 0; i < from.size(); i++) { if (hasElement(to, from.get(i))) { res.add(from.get(i)); } } return res; } public static <E extends Object> List<E> getCommonElements( List<List<E>> sets) { List<E> set = getCommonElements(sets.get(0), sets.get(1)); for (int i = 2; i < sets.size(); i++) { set = getCommonElements(set, sets.get(i)); } return set; } public static <E extends Object> List<E> getCommonElements( Collection<E> from, Collection<E> to) { List<E> res = new ArrayList<E>(); for (E f : from) { for (E t : to) { if (f.equals(t)) { res.add(f); } } } return res; } public static <E extends Object> boolean hasElement(List<E> array, E element) { boolean res = false; for (int i = 0; i < array.size(); i++) { if (array.get(i).equals(element)) { res = true; break; } } return res; } }