Global web icon
stackoverflow.com
https://stackoverflow.com/questions/6203411/compar…
java - Comparing strings by their alphabetical order - Stack Overflow
Note that String#compareTo 's lexicographic comparison will sort capital "Z" before lower-case "a." If you're alphabetizing mixed-case strings, you need locale-sensitive ordering. In case the link to localized ordering of strings goes dead, the thing to use is java.text.Collator.
Global web icon
stackoverflow.com
https://stackoverflow.com/questions/3767090/what-d…
What do the return values of Comparable.compareTo mean in Java?
the Object Ordering section of the Collection Trail in the Sun Java Tutorial Effective Java by Joshua Bloch, especially item 12: Consider implementing Comparable Java Generics and Collections by Maurice Naftalin, Philip Wadler, chapter 3.1: Comparable Warning: you should never rely on the return values of compareTo being -1, 0 and 1.
Global web icon
stackoverflow.com
https://stackoverflow.com/questions/72160928/how-t…
How to implement compareTo method in Java and what does it mean
The compareTo method in your example specifies that when we compare two spaceships we are going to use the string value of their spaceshipClass. Furthermore, the compareTo method in your example uses the default implementation of comparing strings: This means that the strings are compared lexicographically (you can think of it as alphabetical).
Global web icon
stackoverflow.com
https://stackoverflow.com/questions/32443402/how-d…
java - How does compareTo work? - Stack Overflow
Comparison using compareTo does not use correlation: correlation is a symmetric property, whereas compareTo is (or at least should be) anti-symmetric, at least in the sense that sign(a.compareTo(b)) = -sign(b.compareTo(a)).
Global web icon
stackoverflow.com
https://stackoverflow.com/questions/3748805/how-to…
How to use the Comparable CompareTo on Strings in Java
How to use the Comparable CompareTo on Strings in Java Asked 15 years, 2 months ago Modified 5 years ago Viewed 96k times
Global web icon
stackoverflow.com
https://stackoverflow.com/questions/2592501/how-to…
How to compare dates in Java? - Stack Overflow
How do I compare dates in between in Java? Example: date1 is 22-02-2010 date2 is 07-04-2010 today date3 is 25-12-2010 date3 is always greater than date1 and date2 is always today. How do I v...
Global web icon
stackoverflow.com
https://stackoverflow.com/questions/420223/what-is…
java - What is the difference between compare () and compareTo ...
compareTo(T object) comes from the java.lang.Comparable interface, implemented to compare this object with another to give a negative int value for this object being less than, 0 for equals, or positive value for greater than the other. This is the more convenient compare method, but must be implemented in every class you want to compare.
Global web icon
stackoverflow.com
https://stackoverflow.com/questions/513832/how-do-…
How do I compare strings in Java? - Stack Overflow
Option 3: Java String comparison with the compareTo method There is also a third, less common way to compare Java strings, and that's with the String class compareTo method.
Global web icon
stackoverflow.com
https://stackoverflow.com/questions/4064633/string…
String Comparison in Java - Stack Overflow
The Java String class provides the .compareTo () method in order to lexicographically compare Strings. It is used like this "apple".compareTo ("banana"). The return of this method is an int which can be interpreted as follows: returns < 0 then the String calling the method is lexicographically first (comes first in a dictionary)
Global web icon
stackoverflow.com
https://stackoverflow.com/questions/70009499/how-t…
java - How to use compareTo () to compare two objects? - Stack Overflow
It's a good practice to implement compareTo method such that, when its return value is 0, it's like two objects are equals (e.g. firstK.compareTo(secondK) == firstK.equals(secondK)). You can also read Java documentation compareTo documentation.