Here you can find the source of compare(List
public static <T extends Comparable<T>> boolean compare(List<T> a, List<T> b)
//package com.java2s; import java.util.Collections; import java.util.List; public class Main { public static <T extends Comparable<T>> boolean compare(List<T> a, List<T> b) { if (a.size() != b.size()) return false; Collections.sort(a);/*from ww w . j av a 2 s . c o m*/ Collections.sort(b); for (int i = 0; i < a.size(); i++) { if (!a.get(i).equals(b.get(i))) return false; } return true; } }