import java.util.ArrayList; import java.util.Collections; class SortTest> implements Comparable> { R r; public SortTest(R r) { this.r = r; } public int compareTo(SortTest o) { return r.compareTo(o.r); } public static void main(String[] args) { ArrayList> list = new ArrayList>(); SortTest t1 = new SortTest(""); list.add(t1); SortTest t2 = new SortTest(0); list.add(t2); Collections.sort(list); t1.compareTo(t2); //this should be OK SortTest[] arr = new SortTest[0]; arr[0] = new SortTest(""); } }