import java.util.Comparator; public class CompareTester { int i; public static class Inside implements Comparator<CompareTester> { @Override public int compare(CompareTester o1, CompareTester o2) { // TODO Auto-generated method stub System.out.println(o1.i - o2.i); return 0; }}} public class CompareTest { public static void main(String[] args) { CompareTester j = new CompareTester(); j.i = 3; CompareTester k = new CompareTester(); k.i = 5; CompareTester l = new CompareTester(); l.i = 7; CompareTester[] numbers = { j, k, l }; Arrays.sort(numbers, new CompareTester.Inside()); }} These are two classes that are giving two different results in CompareTester class when ran in Java 6 and Java 7.
Is there any different kind of implementation that has been introduced in Java7 for Comparator?
comparewould mean objects are the same for such purpose so the order depends if the algorithm isstableor notComparatoralways return0?