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.

MyClass cannot be cast to java.lang.Comparable: java.lang.ClassCastException

I am doing a java project and I got this problem and don't know how to fix it. The classes …

java sorting exception classcastexception comparable
Create a compareTo to a Generic Class that Implements Comparable

I have a Generic Class with two type variables, which implements java.lang.Comparable. public class DoubleKey<K,J&…

java generics interface comparable
ordering a hashset example?

I need an example on how to use a comparable class on a HashSet to get an ascending order. Let’…

java data-structures hashset comparable sortedset
Comparing the values of two generic Numbers

I want to compare to variables, both of type T extends Number. Now I want to know which of the …

java generics numbers comparable
Comparing Long values using Collections.sort(object)

I'm trying to sort a simple list of objects by a long - the below isn't working because one of …

java sorting comparable
Java Sorting: sort an array of objects by property, object not allowed to use Comparable

I have a class, Library, that contains an array of Book objects, and I need to sort the array based …

java arrays sorting properties comparable
How to override compareTo (Java)

I'm a beginner in programming and I have two classes. First class is: public class User implements Comparable<User&…

java comparable
What is the best way to get min and max value from a list of Comparables that main contain null values?

I am thinking about something like this: public static <T extends Comparable<T>> T minOf(T...…

java collections comparable
Java, how to use compareTo to sort an Arraylist

Im trying to figure out how to sort an ArrayList using comparable, my code looks like this: public class playerComparsion{ …

java comparable compareto
How to create SortedSet (e.g. TreeSet) for elements of type BitSet

I have a number (power(2,k)) of BitSet objects and I want to store them in a SortedSet. I use …

java classcastexception comparable bitset