Top "Comparable" questions

In Java, this interface is implemented by a class to indicate that it can be compared to another object and therefore ordered.

implementing Comparable interface from abstract class with concrete subclasses

package geometricobject; public abstract class GeometricObject implements Comparable { private String color = "white"; private boolean filled; private java.util.Date dateCreated; …

java interface comparable implements
Help comparing float member variables using Comparators

I am able to compare Strings fine, but would like to know how I can rank floating point numbers? getChange() …

java sorting arraylist comparator comparable
Implementing Comparable, compareTo name clash: "have the same erasure, yet neither overrides the other"

I'd like to have a compareTo method that takes a Real (a class for working with arbitrarily large and precise …

java generics overriding comparable erasure
Using Comparable for multiple dynamic fields of VO in java

I have a class public class StudentVO { int age; String name; } I used the same class in two different areas. …

java comparator comparable
Java override compareTo, Long

I have a class that implements the Comparable interface. In this class I need to override compareTo method in order …

java comparable compareto
java.lang.Comparable and equals

If I implement java.lang.Comparable for a class, do I still have to override the equals() method? Or will …

java equals comparable
Comparable and Comparator contract with regards to null

Comparable contract specifies that e.compareTo(null) must throw NullPointerException. From the API: Note that null is not an instance …

java generics null comparator comparable
implementing comprable method in a generic way in Java for sorting

I am trying to implement a generic selection sort which can take any objects and do the sorting on it. …

java sorting generics comparable compareto
Why it is implied that objects are equal if compareTo() returns 0?

Let's have a class Person. Person has a name and height. Equals and hashCode() takes into account only name. Person …

java collections equals comparable compareto
Sorting Java objects using multiple keys

I've got a collection of Duck objects and I'd like to sort them using multiple keys. class Duck { DuckAge age; //…

java sorting comparator comparable