compareTo

Short class in Java

The Short class is a wrapper class for the primitive type short. It contains several methods for dealing with short…

2 years ago

Comparator Interface in Java Collection Framework

To sort the objects of user-defined classes, a comparator interface is utilized. A comparator object can compare two items of…

2 years ago

Comparable Interface in Java

The Comparable interface is used to compare an object of the same class with an instance of that class; it also enables data ordering for user-defined class objects. The class has to implement the java.lang.Comparable interface to compare its instance, it provides the compareTo() method, which accepts an object of that class as an argument. Its sorting algorithm is…

2 years ago