String str1 = "Negan"; String str2 = ""; //empty string //it would return the length of str1 in positive number str1.compareTo(str2); // 5 //it would return the length of str1 in negative number str2.compareTo(str1); //-5
public int compareTo(Jedi jedi){ return this.age > jedi.age ? 1 : this.age < jedi.age ? -1 : 0; }