About 98,900 results
Open links in new tab
  1. 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 …

  2. java - how does compareTo and compare work? - Stack Overflow

    Sep 12, 2012 · sort method makes a call to either compareTo or compare() methods. But how does sort method arranges the list when compare or compareTo returns a int value. What is …

  3. How does compareTo work? (Comparable Interface) Java 8

    Nov 21, 2017 · Java provides two interfaces to sort objects using data members of the class: Comparable and Comparator interfaces Java Comparable interface Java Comparable …

  4. How to implement compareTo method in Java and what does it …

    May 8, 2022 · Did you try debugging it to see the flow? Anyway, this code uses String.compareTo() implementation, if spaceshipClass comparison is not 0, then return the …

  5. What do the return values of Comparable.compareTo mean in Java?

    Sep 22, 2010 · 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 …

  6. How to use the Comparable CompareTo on Strings in Java

    Sep 20, 2010 · How to use the Comparable CompareTo on Strings in Java Asked 15 years, 3 months ago Modified 5 years, 1 month ago Viewed 96k times

  7. java - compareTo () vs. equals () - Stack Overflow

    Oct 11, 2019 · This is an old question, but it contains a nugget I wanted to highlight: " compareTo() == 0 does not necessarily imply equality in all cases". This is absolutely correct! …

  8. java - How does compareTo () work - Stack Overflow

    Sep 12, 2017 · 0 If you look at the parameter on the compareTo function it has "Employee emp" as the parameter, Employee being the type and emp being the name used to refer to it. In …

  9. java - compareTo with primitives -> Integer / int - Stack Overflow

    Feb 5, 2012 · Integer doesn't have an equivalent static method before Java 7. : ( But Double.compare () has the same effect.

  10. java - Does compareTo work with double type? - Stack Overflow

    Apr 10, 2015 · 2 I need to make a program that uses compareTo, but I'm running into issues with it.