Question: what is difference between == equals () and compareto () method?
Answer: equals() checks if two objects are the same or not and returns a boolean. compareTo() (from interface Comparable) returns an integer. It checks which of the two objects is "less than", "equal to" or "greater than" the other. ... Note that equals() doesn't define the ordering between objects, which compareTo() does.