Search code examples
javacompareto

What are the Comparable.compareTo interface semantics?


I don't understand this question. Is it asking the for the method's signature, which is:

public int compareTo(Object o)

or is it: compareTo() returns negative numbers, 0, and positive numbers respectively indicating whether the calling object is less than, equal to, or greater than the specified object?


Solution

  • The instructor is looking for that second answer -- what the return value means. That's the semantics ("meaning") of a method. The signature is the "syntax".