compareTo is an int class method in Scala which is used to compare this with that operand. It is similar to the compare Method.
Returns: return -1 when Given_Value1 is less than Given_Value2. retun 0 when both values are equal. return 1 when Given_Value1 is greater than Given_Value2.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.