get a boolean answer from a custom comparator

Call compare directly and check the result against 0 using the same relational operator. If you want to check -2 > 1, pass those two numbers in as parameters and check if the result is > 0.

Comparator<Integer> comparator = new absComparator();
System.out.println(comparator.compare(-2, 1) > 0);

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top