// This simple class counts the number of times its compareTo is called. // The data it compares is an int. public class ComparisonCounter implements Comparable { private static int counter; private int value; public ComparisonCounter(int value) { this.value = value; } public static int getCounter() { return counter; } public int getValue() { return value; } public String toString() { return "" + value; } public static void resetCounter() { counter = 0; } public int compareTo(Object o) { ComparisonCounter other = (ComparisonCounter)o; counter++; if (valueother.value) return +1; else return 0; } }