Top "Compareto" questions

The CompareTo method is found in the .NET Framework and Java and imposes the natural ordering of a class.

How to write hashCode method for a particular class?

I'm trying to generate a hashCode() method for my simple class but i'm not getting anywhere with it. I would …

java class character hashcode compareto
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
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
Extending comparable interface and override compareTo

I know this has propably been asked 1000 times, and i have seen 1000 answers, but i didn't see any that actually …

java interface comparable compareto
Sorting a List alphabetically using compareTo() method

I am writing a phonebook program in java and i need to list people in the list alphabetically and to …

java list sorting compareto
compareTo() method is not overriding default method when using Comparable interface

I am trying to overwrite the default compareTo() method in java by writing my own and using implements comparable, however …

java interface comparable compareto
Equals and Comparable with Sets

I posted some code here which correctly solved a problem the poster had. OP wanted to remove duplicates and bring …

java equals comparable compareto treeset
FindBugs - how to solve EQ_COMPARETO_USE_OBJECT_EQUALS

I am clueless here... 1: private static class ForeignKeyConstraint implements Comparable<ForeignKeyConstraint> { 2: String tableName; 3: String fkFieldName; 4: 5: public int compareTo(…

java findbugs compareto
Why use TimeSpan.CompareTo() rather than < > or =

I've been going over some Microsoft samples of code for the Kinect sensor and have stumbled across the following line. …

c# .net timespan compareto