Jim Hoglund wrote:On a related subject, I see "return -1;" after your conditional statement.
Since Java does not support using numerical values for T/F conditions,
a boolean (or Boolean) should always be used for this purpose.
Well, no. The compareTo()/compare() methods in Comparable and Comparator, respectively, return an int, so that's what he's returning. Each methods compares two objects and returns a negative number if the first one is "first", 0 if they're "the same" and a positive number if the second one should come first. His pseudocode leaves the "int" return type declaration off of his method -- this is an argument for why
you should always
PostRealCode .