### Question:
ArrayListOfIntsWritable extends ArrayListOfInts implements
    WritableComparable<ArrayListOfIntsWritable> { @Override public int compareTo(ArrayListOfIntsWritable obj) { ArrayListOfIntsWritable other = (ArrayListOfIntsWritable) obj; if (isEmpty()) { if (other.isEmpty()) { return 0; } else { return -1; } } for (int i = 0; i < size(); i++) { if (other.size() <= i) { return 1; } if (get(i) < other.get(i)) { return -1; } else if (get(i) > other.get(i)) { return 1; } } if (other.size() > size()) { return -1; } else { return 0; } } ArrayListOfIntsWritable();  ArrayListOfIntsWritable(int initialCapacity);  ArrayListOfIntsWritable(int first, int last);  ArrayListOfIntsWritable(ArrayListOfIntsWritable other);  ArrayListOfIntsWritable(int[] arr); void readFields(DataInput in); void write(DataOutput out); @Override String toString(); static ArrayListOfIntsWritable fromArrayListOfInts(ArrayListOfInts a); @Override int compareTo(ArrayListOfIntsWritable obj);  }### Answer:
@Test public void testCompare() { ArrayListOfIntsWritable a = new ArrayListOfIntsWritable(); a.add(one).add(three).add(five); ArrayListOfIntsWritable b = new ArrayListOfIntsWritable(); b.add(one).add(three).add(five).add(seven); assertTrue(b.compareTo(a) > 0); b.remove(3); assertTrue(b.compareTo(a) == 0); b.remove(2); assertTrue(b.compareTo(a) < 0); ArrayListOfIntsWritable c = new ArrayListOfIntsWritable(); assertTrue(b.compareTo(c) > 0); assertTrue(c.compareTo(a) < 0); assertTrue(a.compareTo(c) > 0); assertTrue(c.compareTo(b) < 0); }
@Test public void testCompare2() { ArrayListOfIntsWritable a = new ArrayListOfIntsWritable(); a.add(one).add(three).add(six); ArrayListOfIntsWritable b = new ArrayListOfIntsWritable(); b.add(one).add(three).add(four); assertTrue(a.compareTo(b) > 0); ArrayListOfIntsWritable c = new ArrayListOfIntsWritable(); c.add(one).add(three).add(four).add(nine); assertTrue(c.compareTo(a) < 0); assertTrue(b.compareTo(c) < 0); ArrayListOfIntsWritable d = new ArrayListOfIntsWritable(); d.add(two).add(four); ArrayListOfIntsWritable e = new ArrayListOfIntsWritable(); e.add(zero).add(two); assertTrue(d.compareTo(a) > 0); assertTrue(d.compareTo(b) > 0); assertTrue(d.compareTo(c) > 0); assertTrue(e.compareTo(a) < 0); assertTrue(e.compareTo(b) < 0); assertTrue(e.compareTo(c) < 0); assertTrue(e.compareTo(d) < 0); }