public class ComparableTest { public static void main(String[] args) { Comparable[] a = new Comparable[3]; a[0] = new Integer(0); a[1] = new String("hi"); a[2] = new Integer(2); Comparable test = new Integer(1); for (int i=0 ; i < a.length ; i++) if(a[i] instanceof Integer) // what happens if not include this? System.out.println(test.compareTo(a[i])); Comparable[] b = new Integer[3]; b[0] = new Integer(0); // b[1] = new String("hi"); // what happens if include this? b[2] = new Integer(2); for (int i=0 ; i < b.length ; i++) System.out.println(b[i]); Integer[] c = new Integer[2]; c[0] = new Integer(0); c[1] = new Integer(1); Comparable t1 = new Integer(1); Integer t2 = new Integer(1); for (int i=0 ; i < c.length ; i++) { System.out.println(t1.compareTo(c[i])); System.out.println(t2.compareTo(c[i])); } } }