### Question:
ArrayListOfLongsWritable extends ArrayListOfLongs implements
    WritableComparable<ArrayListOfLongsWritable> { @Override public int compareTo(ArrayListOfLongsWritable obj) { ArrayListOfLongsWritable other = (ArrayListOfLongsWritable) 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; } } ArrayListOfLongsWritable();  ArrayListOfLongsWritable(int initialCapacity);  ArrayListOfLongsWritable(int first, int last);  ArrayListOfLongsWritable(ArrayListOfLongsWritable other);  ArrayListOfLongsWritable(long[] arr); void readFields(DataInput in); void write(DataOutput out); @Override String toString(); static ArrayListOfLongsWritable fromArrayListOfLongs(ArrayListOfLongs a); @Override int compareTo(ArrayListOfLongsWritable obj);  }### Answer:
@Test public void testCompare() { ArrayListOfLongsWritable a = new ArrayListOfLongsWritable(); a.add(one).add(three).add(five); ArrayListOfLongsWritable b = new ArrayListOfLongsWritable(); 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); ArrayListOfLongsWritable c = new ArrayListOfLongsWritable(); assertTrue(b.compareTo(c) > 0); assertTrue(c.compareTo(a) < 0); assertTrue(a.compareTo(c) > 0); assertTrue(c.compareTo(b) < 0); }
@Test public void testCompare2() { ArrayListOfLongsWritable a = new ArrayListOfLongsWritable(); a.add(one).add(three).add(six); ArrayListOfLongsWritable b = new ArrayListOfLongsWritable(); b.add(one).add(three).add(four); assertTrue(a.compareTo(b) > 0); ArrayListOfLongsWritable c = new ArrayListOfLongsWritable(); c.add(one).add(three).add(four).add(nine); assertTrue(c.compareTo(a) < 0); assertTrue(b.compareTo(c) < 0); ArrayListOfLongsWritable d = new ArrayListOfLongsWritable(); d.add(two).add(four); ArrayListOfLongsWritable e = new ArrayListOfLongsWritable(); 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); }