DEV Community

Charlie Barajas
Charlie Barajas

Posted on

The compare() method in Java

When we use the compare() or equal() methods, we primarily use them to define the equality of two or more objects that are instances of a class such that Class class_1 = new Class(); would be compared to another instance like class_2. The equality operator (==) cannot be used for objects because of both instance fields and multiple primitive data types being inside each method.

Top comments (0)