Java tutorial
//package com.java2s; import java.util.List; public class Main { public static <T extends Comparable<T>> int compareLists(List<? extends T> a, List<? extends T> b) { int cmp = Integer.valueOf(a.size()).compareTo(Integer.valueOf(b.size())); if (cmp != 0) { return cmp; } for (int i = 0; i < a.size(); ++i) { cmp = a.get(i).compareTo(b.get(i)); if (cmp != 0) { return cmp; } } return 0; } }