About 18,800 results
Open links in new tab
  1. Java : Comparable vs Comparator - Stack Overflow

    Comparable should be implemented inside the object. So there is a dependency created with the compareTo method for a object which will be implied to a particular kind of implementation of …

  2. java - When to use Comparable and Comparator - Stack Overflow

    Feb 15, 2010 · You create separate classes that implement the Comparator interface (or use lambdas in Java 8+) and define the compare () method. This is more flexible since you can …

  3. java - Difference between Comparable and Comparator? - Stack …

    Mar 29, 2018 · Comparable and Comparator are generic interfaces that allow to compare instances of the type defined in the generic (subclasses included). The main difference …

  4. java - What is the difference between compare () and compareTo ...

    Jan 7, 2009 · From JavaNotes: a.compareTo(b): Comparable interface : Compares values and returns an int which tells if the values compare less than, equal, or greater than. If your class …

  5. When should a class be Comparable and/or Comparator?

    Sep 17, 2009 · The text below comes from Comparator vs Comparable Comparable A comparable object is capable of comparing itself with another object. The class itself must …

  6. java - Comparable and Comparator - Stack Overflow

    Feb 25, 2012 · From the Java Documentation on Comparable: This interface imposes a total ordering on the objects of each class that implements it. This ordering is referred to as the …

  7. When should I use Comparator vs Comparable? - Stack Overflow

    May 7, 2022 · It looks like the comparator defines the „natural order“ for Person objects. In this case, you should implement the Comparable interface and compareTo () instead. But …

  8. Java: Comparable vs Comparator - Memory & Performance

    Mar 12, 2020 · During one of my interview, I was asked What is the performance difference between Comparable and Comparator? I replied that I don't know. The interviewer said, If …

  9. java - Diferença entre Comparator e Comparable - Stack Overflow …

    Nov 9, 2018 · Em Java, qual é a diferença entre essas duas interfaces, Comparator e Comparable? Quando usar uma ou outra?

  10. java - В чем разница между Comparable и Comparator? - Stack …

    Mar 14, 2017 · Comparator и Comparable - это оба интерфейсы Коллекция (ну хорошо, объект) является Comparable, когда объект может быть как то сравнен с другим …

Refresh