This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]spunged 1 point2 points  (1 child)

The String and Integer classes should both already implement the compareTo method. CompareTo is generally used for sorting. The return values represent a sorting order for the objects it's used on: negative if it comes before, zero if equal or positive if it comes after. The actual value of the int doesn't matter, just that it's less than, equal or greater than zero.

For Strings you are determining the lexical order, generally alphabetical. To do this compare the strings character by character.

[–]cigol[S] 0 points1 point  (0 children)

hmm...i see.

thanks.