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.

How to implement the Java comparable interface?

I am not sure how to implement a comparable interface into my abstract class. I have the following example code …

java comparable
When should a class be Comparable and/or Comparator?

I have seen classes which implement both Comparable and Comparator. What does this mean? Why would I use one over …

java comparator comparable
Java : Comparable vs Comparator

Possible Duplicates: difference between compare() and compareTo() Java: What is the difference between implementing Comparable and Comparator? What are the …

java comparator comparable
What do the return values of Comparable.compareTo mean in Java?

What is the difference between returning 0, returning 1 and returning -1 in compareTo() in Java?

java comparable
How do I write a compareTo method which compares objects?

I am learning about arrays, and basically I have an array that collects a last name, first name, and score. …

java comparable compareto
When to use Comparable and Comparator

I have a list of objects I need to sort on a field, say Score. Without giving much thought I …

java comparator comparable
How to use the Comparable CompareTo on Strings in Java

I can use it to sort by emp id but I'm not sure if it is possible to compare strings. …

java comparable compareto
Implementing Comparable with a generic class

I want to define a class that implements the generic Comparable interface. While in my class I also defined a …

java generics interface comparable raw-types
Why is compareTo on an Enum final in Java?

An enum in Java implements the Comparable interface. It would have been nice to override Comparable's compareTo method, but here …

java enums comparable compareto
Java Comparator using .reverseOrder() but with an inner class

I am creating a simple program to learn about the Java Comparator class. I have sorted an Arraylist into order …

java sorting comparable