x.compareTo(y) < 0 // x < y
x.compareTo(y) <= 0 // x <= y
x.compareTo(y) != 0 // x != y
x.compareTo(y) == 0 // x == y
x.compareTo(y) > 0 // x > y
x.compareTo(y) >= 0 // x >= y
public int compareTo(Jedi jedi){
return this.age > jedi.age ? 1 : this.age < jedi.age ? -1 : 0;
}
******Java String compareTo()******
The Java String class compareTo() method compares the given
string with the current string lexicographically.
It returns a positive number, negative number, or 0.
___________________________________________
if s1 > s2, it returns positive number
if s1 < s2, it returns negative number
if s1 == s2, it returns 0
___________________________________________
String s1 = "2"
String s2 = "5"
s1.compareTo(s2); //returns difference between 2 Strings
3 //returns positive 3 since s2 string is higehr than s1 by 3