compareto method java

Java
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); //-5String.compareTo();
// will return the difference of the Strings unicode placement
Source

Also in Java: