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.

Java: to use contains in a ArrayList full of custom object should I override equals or implement Comparable/Comparator?

I have an ArrayList full of these: class TransitionState { Position positionA; Position positionB; int counter; public boolean equals (Object o){ …

java collections equals comparator comparable
How does the compareTo() method, compare strings?

Such as if I were to compare the Strings "Hello" and "World". How does it know Hello is greater than …

java string interface comparable compareto
Sorting ArrayList of Arraylist<String> in java

I have an ArrayList of ArrayList of String. In Outer ArrayList on each index each Inner ArrayList has four items …

java sorting arraylist comparator comparable
Why doesn't java.lang.Number implement Comparable?

Does anyone know why java.lang.Number does not implement Comparable? This means that you cannot sort Numbers with Collections.…

java sorting comparable
Does a natural comparator exist in the standard api?

I need a comparator as part of a strategy pattern that can either use the natural ordering of the objects …

java comparator comparable
Cannot invoke compareTo(double) on the primitive type double

The line return array[index1].compareTo(array[index2]); provides an error "Cannot invoke compareTo(double) on the primitive type double". …

java compare comparable compareto
How to sort based on/compare multiple values in Kotlin?

Say I have a class Foo(val a: String, val b: Int, val c: Date) and I want to sort …

comparable kotlin
Java "unchecked call to compareTo(T) as a member of the raw type java.lang.Comparable"

I'm trying to implement a sorted list as a simple exercise in Java. To make it generic I have an …

java generics comparable unchecked
Java "cannot cast to Comparable" when using TreeMap

Possible Duplicate: Java: SortedMap, TreeMap, Comparable? How to use? I am using the Java JungI graph package and Netbeans 7. I …

java casting treemap comparable sortedmap
How do I make 2 comparable methods in only one class?

I've got one class, that I sort it already by one attribute. Now I need to make another thing, that …

java sorting collections comparable