Top "Compareto" questions

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

Comparison method violates its general contract! Java 7 only

I know this has been an issue for a while now, and checked all previously answers I could get, but …

java-7 compareto
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
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
What should int compareTo() return when the parameter string is null?

It is said that when input parameter is null, compareTo() should throw a NullPointerException. However, I am implementing a class …

java string null nullpointerexception compareto
abstract compareTo method not being overrided

When compiling the code below, I get the following error: PersonalInformation is not abstract and does not override abstract method …

java compiler-errors compareto
What integer does DateTime.CompareTo actually return?

I have been looking for an answer for some time now, but nowhere could I actually find it. I was …

c# datetime compareto
Java: Three strings, lexicographic order

beginner Java programmer here. I am trying to compare three strings to each other, and have the system spit out …

java compareto lexicographic
How does compareTo work?

I know that compareTo returns a negative or positive result on how well one string correlates to the other, but …

java equals comparable compareto
Java compareTo for String and Integer arguments

I am implementing the bubble sort algorithm and I want it to be able to accept both Integer and String …

java compareto
Overriding compareTo method in order to sort objects by String values

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

java compareto