Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Choosing to implement the Comparable interface represents a commitment that the implementation of the compareTo() method adheres to the general usage contract for that method regarding how the method is to be called. Library classes such as TreeSet and TreeMap accept Comparable objects and use the associated compareTo() methods to sort the objects. However, a class that implements the compareTo() method in an unexpected way can cause undesirable results.

Wiki Markup
The general usage contract for {{compareTo()}} from Java SE 6 API \[[API 2006|AA. Bibliography#API 06]] (numbering added) states that

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="443f4adef2660e05-985a10bc-422e44ec-97fc813c-c9312363f6c9121cf5a08e00"><ac:plain-text-body><![CDATA[

[[API 2006

AA. Bibliography#API 06]]

[Method compareTo()

http://java.sun.com/javase/6/docs/api/java/lang/Comparable.html#compareTo(java.lang.Object)]

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="0822648dc13c66bd-11e81c19-406e4dba-a7ffa1e0-c49913377f68253df8141bd0"><ac:plain-text-body><![CDATA[

[[JLS 2005

AA. Bibliography#JLS 05]]

 

]]></ac:plain-text-body></ac:structured-macro>

...