CINXE.COM
Comparable (Java SE 10 & JDK 10 )
<!DOCTYPE HTML> <!-- NewPage --> <html lang="en"> <head> <!-- Generated by javadoc --> <title>Comparable (Java SE 10 & JDK 10 )</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="keywords" content="java.lang.Comparable interface"> <meta name="keywords" content="compareTo()"> <link rel="stylesheet" type="text/css" href="../../stylesheet.css" title="Style"> <link rel="stylesheet" type="text/css" href="../../jquery/jquery-ui.css" title="Style"> <script type="text/javascript" src="../../script.js"></script> <script type="text/javascript" src="../../jquery/jszip/dist/jszip.min.js"></script> <script type="text/javascript" src="../../jquery/jszip-utils/dist/jszip-utils.min.js"></script> <!--[if IE]> <script type="text/javascript" src="../../jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script> <![endif]--> <script type="text/javascript" src="../../jquery/jquery-1.10.2.js"></script> <script type="text/javascript" src="../../jquery/jquery-ui.js"></script> <script>window.ohcglobal || document.write('<script src="/en/dcommon/js/global.js">\x3C/script>')</script></head> <body> <script type="text/javascript"><!-- try { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Comparable (Java SE 10 & JDK 10 )"; } } catch(err) { } //--> var methods = {"i0":6}; var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],4:["t3","Abstract Methods"]}; var altColor = "altColor"; var rowColor = "rowColor"; var tableTab = "tableTab"; var activeTableTab = "activeTableTab"; var pathtoroot = "../../";loadScripts(document, 'script');</script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <header role="banner"> <nav role="navigation"> <div class="fixedNav"> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a id="navbar.top"> <!-- --> </a> <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> <a id="navbar.top.firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../overview-summary.html">Overview</a></li> <li><a href="../../java.base-summary.html">Module</a></li> <li><a href="package-summary.html">Package</a></li> <li class="navBarCell1Rev">Class</li> <li><a href="class-use/Comparable.html">Use</a></li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../deprecated-list.html">Deprecated</a></li> <li><a href="../../index-files/index-1.html">Index</a></li> <li><a href="../../help-doc.html">Help</a></li> </ul> <div class="aboutLanguage"><div style="margin-top: 14px;"><strong>Java SE 10 & JDK 10</strong> </div></div> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../java/lang/CloneNotSupportedException.html" title="class in java.lang"><span class="typeNameLink">Prev Class</span></a></li> <li><a href="../../java/lang/Compiler.html" title="class in java.lang"><span class="typeNameLink">Next Class</span></a></li> </ul> <ul class="navList"> <li><a href="../../index.html?java/lang/Comparable.html" target="_top">Frames</a></li> <li><a href="Comparable.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_top"> <li><a href="../../allclasses-noframe.html">All Classes</a></li> </ul> <ul class="navListSearch"> <li><label for="search">SEARCH:</label> <input type="text" id="search" value="search" disabled="disabled"> <input type="reset" id="reset" value="reset" disabled="disabled"> </li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_top"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> </div> <div> <ul class="subNavList"> <li>Summary: </li> <li>Nested | </li> <li>Field | </li> <li>Constr | </li> <li><a href="#method.summary">Method</a></li> </ul> <ul class="subNavList"> <li>Detail: </li> <li>Field | </li> <li>Constr | </li> <li><a href="#method.detail">Method</a></li> </ul> </div> <a id="skip.navbar.top"> <!-- --> </a></div> <!-- ========= END OF TOP NAVBAR ========= --> </div> <div class="navPadding"> </div> <script type="text/javascript"><!-- $('.navPadding').css('padding-top', $('.fixedNav').css("height")); //--> </script> </nav> </header> <!-- ======== START OF CLASS DATA ======== --> <main role="main"> <div class="header"> <div class="subTitle"><span class="moduleLabelInType">Module</span> <a href="../../java.base-summary.html">java.base</a></div> <div class="subTitle"><span class="packageLabelInType">Package</span> <a href="../../java/lang/package-summary.html">java.lang</a></div> <h2 title="Interface Comparable" class="title">Interface Comparable<T></h2> </div> <div class="contentContainer"> <div class="description"> <ul class="blockList"> <li class="blockList"> <dl> <dt><span class="paramLabel">Type Parameters:</span></dt> <dd><code>T</code> - the type of objects that this object may be compared to</dd> </dl> <dl> <dt>All Known Subinterfaces:</dt> <dd><code><a href="../../com/sun/javadoc/AnnotationTypeDoc.html" title="interface in com.sun.javadoc">AnnotationTypeDoc</a></code>, <code><a href="../../com/sun/javadoc/AnnotationTypeElementDoc.html" title="interface in com.sun.javadoc">AnnotationTypeElementDoc</a></code>, <code><a href="../../com/sun/jdi/ArrayType.html" title="interface in com.sun.jdi">ArrayType</a></code>, <code><a href="../../com/sun/jdi/ByteValue.html" title="interface in com.sun.jdi">ByteValue</a></code>, <code><a href="../../com/sun/jdi/CharValue.html" title="interface in com.sun.jdi">CharValue</a></code>, <code><a href="../../java/time/chrono/ChronoLocalDate.html" title="interface in java.time.chrono">ChronoLocalDate</a></code>, <code><a href="../../java/time/chrono/ChronoLocalDateTime.html" title="interface in java.time.chrono">ChronoLocalDateTime</a><D></code>, <code><a href="../../java/time/chrono/Chronology.html" title="interface in java.time.chrono">Chronology</a></code>, <code><a href="../../java/time/chrono/ChronoZonedDateTime.html" title="interface in java.time.chrono">ChronoZonedDateTime</a><D></code>, <code><a href="../../com/sun/javadoc/ClassDoc.html" title="interface in com.sun.javadoc">ClassDoc</a></code>, <code><a href="../../com/sun/jdi/ClassType.html" title="interface in com.sun.jdi">ClassType</a></code>, <code><a href="../../com/sun/javadoc/ConstructorDoc.html" title="interface in com.sun.javadoc">ConstructorDoc</a></code>, <code><a href="../../java/util/concurrent/Delayed.html" title="interface in java.util.concurrent">Delayed</a></code>, <code><a href="../../com/sun/javadoc/Doc.html" title="interface in com.sun.javadoc">Doc</a></code>, <code><a href="../../com/sun/jdi/DoubleValue.html" title="interface in com.sun.jdi">DoubleValue</a></code>, <code><a href="../../com/sun/javadoc/ExecutableMemberDoc.html" title="interface in com.sun.javadoc">ExecutableMemberDoc</a></code>, <code><a href="../../com/sun/jdi/Field.html" title="interface in com.sun.jdi">Field</a></code>, <code><a href="../../com/sun/javadoc/FieldDoc.html" title="interface in com.sun.javadoc">FieldDoc</a></code>, <code><a href="../../com/sun/jdi/FloatValue.html" title="interface in com.sun.jdi">FloatValue</a></code>, <code><a href="../../com/sun/jdi/IntegerValue.html" title="interface in com.sun.jdi">IntegerValue</a></code>, <code><a href="../../com/sun/jdi/InterfaceType.html" title="interface in com.sun.jdi">InterfaceType</a></code>, <code><a href="../../com/sun/jdi/LocalVariable.html" title="interface in com.sun.jdi">LocalVariable</a></code>, <code><a href="../../com/sun/jdi/Location.html" title="interface in com.sun.jdi">Location</a></code>, <code><a href="../../com/sun/jdi/LongValue.html" title="interface in com.sun.jdi">LongValue</a></code>, <code><a href="../../com/sun/javadoc/MemberDoc.html" title="interface in com.sun.javadoc">MemberDoc</a></code>, <code><a href="../../com/sun/jdi/Method.html" title="interface in com.sun.jdi">Method</a></code>, <code><a href="../../com/sun/javadoc/MethodDoc.html" title="interface in com.sun.javadoc">MethodDoc</a></code>, <code><a href="../../javax/naming/Name.html" title="interface in javax.naming">Name</a></code>, <code><a href="../../com/sun/javadoc/PackageDoc.html" title="interface in com.sun.javadoc">PackageDoc</a></code>, <code><a href="../../java/nio/file/Path.html" title="interface in java.nio.file">Path</a></code>, <code><a href="../../java/lang/ProcessHandle.html" title="interface in java.lang">ProcessHandle</a></code>, <code><a href="../../com/sun/javadoc/ProgramElementDoc.html" title="interface in com.sun.javadoc">ProgramElementDoc</a></code>, <code><a href="../../com/sun/jdi/ReferenceType.html" title="interface in com.sun.jdi">ReferenceType</a></code>, <code><a href="../../com/sun/javadoc/RootDoc.html" title="interface in com.sun.javadoc">RootDoc</a></code>, <code><a href="../../java/util/concurrent/RunnableScheduledFuture.html" title="interface in java.util.concurrent">RunnableScheduledFuture</a><V></code>, <code><a href="../../java/util/concurrent/ScheduledFuture.html" title="interface in java.util.concurrent">ScheduledFuture</a><V></code>, <code><a href="../../com/sun/javadoc/SerialFieldTag.html" title="interface in com.sun.javadoc">SerialFieldTag</a></code>, <code><a href="../../com/sun/jdi/ShortValue.html" title="interface in com.sun.jdi">ShortValue</a></code></dd> </dl> <dl> <dt>All Known Implementing Classes:</dt> <dd><code><a href="../../java/time/chrono/AbstractChronology.html" title="class in java.time.chrono">AbstractChronology</a></code>, <code><a href="../../javax/swing/plaf/nimbus/AbstractRegionPainter.PaintContext.CacheMode.html" title="enum in javax.swing.plaf.nimbus">AbstractRegionPainter.PaintContext.CacheMode</a></code>, <code><a href="../../javafx/scene/AccessibleAction.html" title="enum in javafx.scene">AccessibleAction</a></code>, <code><a href="../../javafx/scene/AccessibleAttribute.html" title="enum in javafx.scene">AccessibleAttribute</a></code>, <code><a href="../../javafx/scene/AccessibleRole.html" title="enum in javafx.scene">AccessibleRole</a></code>, <code><a href="../../java/nio/file/AccessMode.html" title="enum in java.nio.file">AccessMode</a></code>, <code><a href="../../java/nio/file/attribute/AclEntryFlag.html" title="enum in java.nio.file.attribute">AclEntryFlag</a></code>, <code><a href="../../java/nio/file/attribute/AclEntryPermission.html" title="enum in java.nio.file.attribute">AclEntryPermission</a></code>, <code><a href="../../java/nio/file/attribute/AclEntryType.html" title="enum in java.nio.file.attribute">AclEntryType</a></code>, <code><a href="../../javax/xml/ws/soap/AddressingFeature.Responses.html" title="enum in javax.xml.ws.soap">AddressingFeature.Responses</a></code>, <code><a href="../../javafx/scene/control/Alert.AlertType.html" title="enum in javafx.scene.control">Alert.AlertType</a></code>, <code><a href="../../javafx/animation/Animation.Status.html" title="enum in javafx.animation">Animation.Status</a></code>, <code><a href="../../javafx/scene/shape/ArcType.html" title="enum in javafx.scene.shape">ArcType</a></code>, <code><a href="../../com/sun/nio/sctp/AssociationChangeNotification.AssocChangeEvent.html" title="enum in com.sun.nio.sctp">AssociationChangeNotification.AssocChangeEvent</a></code>, <code><a href="../../com/sun/source/doctree/AttributeTree.ValueKind.html" title="enum in com.sun.source.doctree">AttributeTree.ValueKind</a></code>, <code><a href="../../java/net/Authenticator.RequestorType.html" title="enum in java.net">Authenticator.RequestorType</a></code>, <code><a href="../../javafx/scene/layout/BackgroundRepeat.html" title="enum in javafx.scene.layout">BackgroundRepeat</a></code>, <code><a href="../../java/math/BigDecimal.html" title="class in java.math">BigDecimal</a></code>, <code><a href="../../java/math/BigInteger.html" title="class in java.math">BigInteger</a></code>, <code><a href="../../javafx/scene/effect/BlendMode.html" title="enum in javafx.scene.effect">BlendMode</a></code>, <code><a href="../../javafx/scene/effect/BlurType.html" title="enum in javafx.scene.effect">BlurType</a></code>, <code><a href="../../java/lang/Boolean.html" title="class in java.lang">Boolean</a></code>, <code><a href="../../javafx/scene/layout/BorderRepeat.html" title="enum in javafx.scene.layout">BorderRepeat</a></code>, <code><a href="../../javafx/scene/control/ButtonBar.ButtonData.html" title="enum in javafx.scene.control">ButtonBar.ButtonData</a></code>, <code><a href="../../java/lang/Byte.html" title="class in java.lang">Byte</a></code>, <code><a href="../../java/nio/ByteBuffer.html" title="class in java.nio">ByteBuffer</a></code>, <code><a href="../../javafx/scene/CacheHint.html" title="enum in javafx.scene">CacheHint</a></code>, <code><a href="../../java/util/Calendar.html" title="class in java.util">Calendar</a></code>, <code><a href="../../javax/smartcardio/CardTerminals.State.html" title="enum in javax.smartcardio">CardTerminals.State</a></code>, <code><a href="../../javax/xml/catalog/CatalogFeatures.Feature.html" title="enum in javax.xml.catalog">CatalogFeatures.Feature</a></code>, <code><a href="../../java/security/cert/CertPathValidatorException.BasicReason.html" title="enum in java.security.cert">CertPathValidatorException.BasicReason</a></code>, <code><a href="../../java/lang/Character.html" title="class in java.lang">Character</a></code>, <code><a href="../../java/lang/Character.UnicodeScript.html" title="enum in java.lang">Character.UnicodeScript</a></code>, <code><a href="../../java/nio/CharBuffer.html" title="class in java.nio">CharBuffer</a></code>, <code><a href="../../java/nio/charset/Charset.html" title="class in java.nio.charset">Charset</a></code>, <code><a href="../../java/time/temporal/ChronoField.html" title="enum in java.time.temporal">ChronoField</a></code>, <code><a href="../../java/time/temporal/ChronoUnit.html" title="enum in java.time.temporal">ChronoUnit</a></code>, <code><a href="../../java/sql/ClientInfoStatus.html" title="enum in java.sql">ClientInfoStatus</a></code>, <code><a href="../../javafx/print/Collation.html" title="enum in javafx.print">Collation</a></code>, <code><a href="../../java/text/CollationKey.html" title="class in java.text">CollationKey</a></code>, <code><a href="../../java/util/stream/Collector.Characteristics.html" title="enum in java.util.stream">Collector.Characteristics</a></code>, <code><a href="../../java/awt/Component.BaselineResizeBehavior.html" title="enum in java.awt">Component.BaselineResizeBehavior</a></code>, <code><a href="../../javax/naming/CompositeName.html" title="class in javax.naming">CompositeName</a></code>, <code><a href="../../javax/naming/CompoundName.html" title="class in javax.naming">CompoundName</a></code>, <code><a href="../../javafx/application/ConditionalFeature.html" title="enum in javafx.application">ConditionalFeature</a></code>, <code><a href="../../javafx/scene/control/ContentDisplay.html" title="enum in javafx.scene.control">ContentDisplay</a></code>, <code><a href="../../jdk/dynalink/linker/ConversionComparator.Comparison.html" title="enum in jdk.dynalink.linker">ConversionComparator.Comparison</a></code>, <code><a href="../../java/security/cert/CRLReason.html" title="enum in java.security.cert">CRLReason</a></code>, <code><a href="../../java/security/CryptoPrimitive.html" title="enum in java.security">CryptoPrimitive</a></code>, <code><a href="../../javafx/scene/shape/CullFace.html" title="enum in javafx.scene.shape">CullFace</a></code>, <code><a href="../../javafx/scene/paint/CycleMethod.html" title="enum in javafx.scene.paint">CycleMethod</a></code>, <code><a href="../../java/sql/Date.html" title="class in java.sql">Date</a></code>, <code><a href="../../java/util/Date.html" title="class in java.util">Date</a></code>, <code><a href="../../java/time/DayOfWeek.html" title="enum in java.time">DayOfWeek</a></code>, <code><a href="../../javafx/scene/DepthTest.html" title="enum in javafx.scene">DepthTest</a></code>, <code><a href="../../java/awt/Desktop.Action.html" title="enum in java.awt">Desktop.Action</a></code>, <code><a href="../../javax/tools/Diagnostic.Kind.html" title="enum in javax.tools">Diagnostic.Kind</a></code>, <code><a href="../../jdk/nashorn/api/tree/Diagnostic.Kind.html" title="enum in jdk.nashorn.api.tree">Diagnostic.Kind</a></code>, <code><a href="../../java/awt/Dialog.ModalExclusionType.html" title="enum in java.awt">Dialog.ModalExclusionType</a></code>, <code><a href="../../java/awt/Dialog.ModalityType.html" title="enum in java.awt">Dialog.ModalityType</a></code>, <code><a href="../../jdk/javadoc/doclet/Doclet.Option.Kind.html" title="enum in jdk.javadoc.doclet">Doclet.Option.Kind</a></code>, <code><a href="../../jdk/javadoc/doclet/DocletEnvironment.ModuleMode.html" title="enum in jdk.javadoc.doclet">DocletEnvironment.ModuleMode</a></code>, <code><a href="../../com/sun/source/doctree/DocTree.Kind.html" title="enum in com.sun.source.doctree">DocTree.Kind</a></code>, <code><a href="../../javax/tools/DocumentationTool.Location.html" title="enum in javax.tools">DocumentationTool.Location</a></code>, <code><a href="../../java/lang/Double.html" title="class in java.lang">Double</a></code>, <code><a href="../../java/nio/DoubleBuffer.html" title="class in java.nio">DoubleBuffer</a></code>, <code><a href="../../javafx/scene/shape/DrawMode.html" title="enum in javafx.scene.shape">DrawMode</a></code>, <code><a href="../../java/security/DrbgParameters.Capability.html" title="enum in java.security">DrbgParameters.Capability</a></code>, <code><a href="../../javax/swing/DropMode.html" title="enum in javax.swing">DropMode</a></code>, <code><a href="../../java/time/Duration.html" title="class in java.time">Duration</a></code>, <code><a href="../../javafx/util/Duration.html" title="class in javafx.util">Duration</a></code>, <code><a href="../../javax/lang/model/element/ElementKind.html" title="enum in javax.lang.model.element">ElementKind</a></code>, <code><a href="../../javax/lang/model/util/Elements.Origin.html" title="enum in javax.lang.model.util">Elements.Origin</a></code>, <code><a href="../../java/lang/annotation/ElementType.html" title="enum in java.lang.annotation">ElementType</a></code>, <code><a href="../../java/lang/Enum.html" title="class in java.lang">Enum</a></code>, <code><a href="../../java/io/File.html" title="class in java.io">File</a></code>, <code><a href="../../java/nio/file/attribute/FileTime.html" title="class in java.nio.file.attribute">FileTime</a></code>, <code><a href="../../java/nio/file/FileVisitOption.html" title="enum in java.nio.file">FileVisitOption</a></code>, <code><a href="../../java/nio/file/FileVisitResult.html" title="enum in java.nio.file">FileVisitResult</a></code>, <code><a href="../../javafx/scene/shape/FillRule.html" title="enum in javafx.scene.shape">FillRule</a></code>, <code><a href="../../java/lang/Float.html" title="class in java.lang">Float</a></code>, <code><a href="../../java/nio/FloatBuffer.html" title="class in java.nio">FloatBuffer</a></code>, <code><a href="../../java/awt/event/FocusEvent.Cause.html" title="enum in java.awt.event">FocusEvent.Cause</a></code>, <code><a href="../../javafx/scene/text/FontPosture.html" title="enum in javafx.scene.text">FontPosture</a></code>, <code><a href="../../javafx/scene/text/FontSmoothingType.html" title="enum in javafx.scene.text">FontSmoothingType</a></code>, <code><a href="../../javafx/scene/text/FontWeight.html" title="enum in javafx.scene.text">FontWeight</a></code>, <code><a href="../../java/time/format/FormatStyle.html" title="enum in java.time.format">FormatStyle</a></code>, <code><a href="../../java/util/Formatter.BigDecimalLayoutForm.html" title="enum in java.util">Formatter.BigDecimalLayoutForm</a></code>, <code><a href="../../javax/swing/text/html/FormSubmitEvent.MethodType.html" title="enum in javax.swing.text.html">FormSubmitEvent.MethodType</a></code>, <code><a href="../../java/awt/GraphicsDevice.WindowTranslucency.html" title="enum in java.awt">GraphicsDevice.WindowTranslucency</a></code>, <code><a href="../../java/util/GregorianCalendar.html" title="class in java.util">GregorianCalendar</a></code>, <code><a href="../../javax/swing/GroupLayout.Alignment.html" title="enum in javax.swing">GroupLayout.Alignment</a></code>, <code><a href="../../com/sun/nio/sctp/HandlerResult.html" title="enum in com.sun.nio.sctp">HandlerResult</a></code>, <code><a href="../../java/time/chrono/HijrahChronology.html" title="class in java.time.chrono">HijrahChronology</a></code>, <code><a href="../../java/time/chrono/HijrahDate.html" title="class in java.time.chrono">HijrahDate</a></code>, <code><a href="../../java/time/chrono/HijrahEra.html" title="enum in java.time.chrono">HijrahEra</a></code>, <code><a href="../../javafx/geometry/HorizontalDirection.html" title="enum in javafx.geometry">HorizontalDirection</a></code>, <code><a href="../../javafx/geometry/HPos.html" title="enum in javafx.geometry">HPos</a></code>, <code><a href="../../javafx/scene/web/HTMLEditorSkin.Command.html" title="enum in javafx.scene.web">HTMLEditorSkin.Command</a></code>, <code><a href="../../jdk/incubator/http/HttpClient.Redirect.html" title="enum in jdk.incubator.http">HttpClient.Redirect</a></code>, <code><a href="../../jdk/incubator/http/HttpClient.Version.html" title="enum in jdk.incubator.http">HttpClient.Version</a></code>, <code><a href="../../javafx/scene/input/InputMethodHighlight.html" title="enum in javafx.scene.input">InputMethodHighlight</a></code>, <code><a href="../../com/sun/security/jgss/InquireType.html" title="enum in com.sun.security.jgss">InquireType</a></code>, <code><a href="../../java/time/Instant.html" title="class in java.time">Instant</a></code>, <code><a href="../../java/nio/IntBuffer.html" title="class in java.nio">IntBuffer</a></code>, <code><a href="../../java/lang/Integer.html" title="class in java.lang">Integer</a></code>, <code><a href="../../java/time/chrono/IsoChronology.html" title="class in java.time.chrono">IsoChronology</a></code>, <code><a href="../../java/time/chrono/IsoEra.html" title="enum in java.time.chrono">IsoEra</a></code>, <code><a href="../../java/time/chrono/JapaneseChronology.html" title="class in java.time.chrono">JapaneseChronology</a></code>, <code><a href="../../java/time/chrono/JapaneseDate.html" title="class in java.time.chrono">JapaneseDate</a></code>, <code><a href="../../javax/tools/JavaFileObject.Kind.html" title="enum in javax.tools">JavaFileObject.Kind</a></code>, <code><a href="../../com/sun/tools/jconsole/JConsoleContext.ConnectionState.html" title="enum in com.sun.tools.jconsole">JConsoleContext.ConnectionState</a></code>, <code><a href="../../java/sql/JDBCType.html" title="enum in java.sql">JDBCType</a></code>, <code><a href="../../javax/swing/JTable.PrintMode.html" title="enum in javax.swing">JTable.PrintMode</a></code>, <code><a href="../../javafx/scene/input/KeyCode.html" title="enum in javafx.scene.input">KeyCode</a></code>, <code><a href="../../javafx/scene/input/KeyCombination.ModifierValue.html" title="enum in javafx.scene.input">KeyCombination.ModifierValue</a></code>, <code><a href="../../java/security/KeyRep.Type.html" title="enum in java.security">KeyRep.Type</a></code>, <code><a href="../../com/sun/source/tree/LambdaExpressionTree.BodyKind.html" title="enum in com.sun.source.tree">LambdaExpressionTree.BodyKind</a></code>, <code><a href="../../com/sun/javadoc/LanguageVersion.html" title="enum in com.sun.javadoc">LanguageVersion</a></code>, <code><a href="../../javax/swing/LayoutStyle.ComponentPlacement.html" title="enum in javax.swing">LayoutStyle.ComponentPlacement</a></code>, <code><a href="../../javax/naming/ldap/LdapName.html" title="class in javax.naming.ldap">LdapName</a></code>, <code><a href="../../javafx/scene/chart/LineChart.SortingPolicy.html" title="enum in javafx.scene.chart">LineChart.SortingPolicy</a></code>, <code><a href="../../java/nio/file/LinkOption.html" title="enum in java.nio.file">LinkOption</a></code>, <code><a href="../../java/time/LocalDate.html" title="class in java.time">LocalDate</a></code>, <code><a href="../../java/time/LocalDateTime.html" title="class in java.time">LocalDateTime</a></code>, <code><a href="../../java/util/Locale.Category.html" title="enum in java.util">Locale.Category</a></code>, <code><a href="../../java/util/Locale.FilteringMode.html" title="enum in java.util">Locale.FilteringMode</a></code>, <code><a href="../../java/util/Locale.IsoCountryCode.html" title="enum in java.util">Locale.IsoCountryCode</a></code>, <code><a href="../../java/time/LocalTime.html" title="class in java.time">LocalTime</a></code>, <code><a href="../../java/lang/Long.html" title="class in java.lang">Long</a></code>, <code><a href="../../java/nio/LongBuffer.html" title="class in java.nio">LongBuffer</a></code>, <code><a href="../../java/nio/MappedByteBuffer.html" title="class in java.nio">MappedByteBuffer</a></code>, <code><a href="../../javafx/css/Match.html" title="class in javafx.css">Match</a></code>, <code><a href="../../javafx/scene/transform/MatrixType.html" title="enum in javafx.scene.transform">MatrixType</a></code>, <code><a href="../../javafx/scene/media/MediaException.Type.html" title="enum in javafx.scene.media">MediaException.Type</a></code>, <code><a href="../../javafx/scene/media/MediaPlayer.Status.html" title="enum in javafx.scene.media">MediaPlayer.Status</a></code>, <code><a href="../../com/sun/source/tree/MemberReferenceTree.ReferenceMode.html" title="enum in com.sun.source.tree">MemberReferenceTree.ReferenceMode</a></code>, <code><a href="../../java/lang/management/MemoryType.html" title="enum in java.lang.management">MemoryType</a></code>, <code><a href="../../javax/xml/ws/handler/MessageContext.Scope.html" title="enum in javax.xml.ws.handler">MessageContext.Scope</a></code>, <code><a href="../../java/time/chrono/MinguoChronology.html" title="class in java.time.chrono">MinguoChronology</a></code>, <code><a href="../../java/time/chrono/MinguoDate.html" title="class in java.time.chrono">MinguoDate</a></code>, <code><a href="../../java/time/chrono/MinguoEra.html" title="enum in java.time.chrono">MinguoEra</a></code>, <code><a href="../../javafx/stage/Modality.html" title="enum in javafx.stage">Modality</a></code>, <code><a href="../../javax/lang/model/element/Modifier.html" title="enum in javax.lang.model.element">Modifier</a></code>, <code><a href="../../java/lang/module/ModuleDescriptor.html" title="class in java.lang.module">ModuleDescriptor</a></code>, <code><a href="../../java/lang/module/ModuleDescriptor.Exports.html" title="class in java.lang.module">ModuleDescriptor.Exports</a></code>, <code><a href="../../java/lang/module/ModuleDescriptor.Exports.Modifier.html" title="enum in java.lang.module">ModuleDescriptor.Exports.Modifier</a></code>, <code><a href="../../java/lang/module/ModuleDescriptor.Modifier.html" title="enum in java.lang.module">ModuleDescriptor.Modifier</a></code>, <code><a href="../../java/lang/module/ModuleDescriptor.Opens.html" title="class in java.lang.module">ModuleDescriptor.Opens</a></code>, <code><a href="../../java/lang/module/ModuleDescriptor.Opens.Modifier.html" title="enum in java.lang.module">ModuleDescriptor.Opens.Modifier</a></code>, <code><a href="../../java/lang/module/ModuleDescriptor.Provides.html" title="class in java.lang.module">ModuleDescriptor.Provides</a></code>, <code><a href="../../java/lang/module/ModuleDescriptor.Requires.html" title="class in java.lang.module">ModuleDescriptor.Requires</a></code>, <code><a href="../../java/lang/module/ModuleDescriptor.Requires.Modifier.html" title="enum in java.lang.module">ModuleDescriptor.Requires.Modifier</a></code>, <code><a href="../../java/lang/module/ModuleDescriptor.Version.html" title="class in java.lang.module">ModuleDescriptor.Version</a></code>, <code><a href="../../javax/lang/model/element/ModuleElement.DirectiveKind.html" title="enum in javax.lang.model.element">ModuleElement.DirectiveKind</a></code>, <code><a href="../../com/sun/source/tree/ModuleTree.ModuleKind.html" title="enum in com.sun.source.tree">ModuleTree.ModuleKind</a></code>, <code><a href="../../java/time/Month.html" title="enum in java.time">Month</a></code>, <code><a href="../../java/time/MonthDay.html" title="class in java.time">MonthDay</a></code>, <code><a href="../../javafx/scene/input/MouseButton.html" title="enum in javafx.scene.input">MouseButton</a></code>, <code><a href="../../java/awt/MultipleGradientPaint.ColorSpaceType.html" title="enum in java.awt">MultipleGradientPaint.ColorSpaceType</a></code>, <code><a href="../../java/awt/MultipleGradientPaint.CycleMethod.html" title="enum in java.awt">MultipleGradientPaint.CycleMethod</a></code>, <code><a href="../../javax/lang/model/element/NestingKind.html" title="enum in javax.lang.model.element">NestingKind</a></code>, <code><a href="../../javafx/geometry/NodeOrientation.html" title="enum in javafx.geometry">NodeOrientation</a></code>, <code><a href="../../java/text/Normalizer.Form.html" title="enum in java.text">Normalizer.Form</a></code>, <code><a href="../../java/awt/font/NumericShaper.Range.html" title="enum in java.awt.font">NumericShaper.Range</a></code>, <code><a href="../../java/io/ObjectInputFilter.Status.html" title="enum in java.io">ObjectInputFilter.Status</a></code>, <code><a href="../../javax/management/ObjectName.html" title="class in javax.management">ObjectName</a></code>, <code><a href="../../java/io/ObjectStreamField.html" title="class in java.io">ObjectStreamField</a></code>, <code><a href="../../java/time/OffsetDateTime.html" title="class in java.time">OffsetDateTime</a></code>, <code><a href="../../java/time/OffsetTime.html" title="class in java.time">OffsetTime</a></code>, <code><a href="../../javafx/geometry/Orientation.html" title="enum in javafx.geometry">Orientation</a></code>, <code><a href="../../javafx/scene/control/OverrunStyle.html" title="enum in javafx.scene.control">OverrunStyle</a></code>, <code><a href="../../javafx/print/PageOrientation.html" title="enum in javafx.print">PageOrientation</a></code>, <code><a href="../../javafx/animation/PathTransition.OrientationType.html" title="enum in javafx.animation">PathTransition.OrientationType</a></code>, <code><a href="../../com/sun/nio/sctp/PeerAddressChangeNotification.AddressChangeEvent.html" title="enum in com.sun.nio.sctp">PeerAddressChangeNotification.AddressChangeEvent</a></code>, <code><a href="../../javafx/scene/image/PixelFormat.Type.html" title="enum in javafx.scene.image">PixelFormat.Type</a></code>, <code><a href="../../java/security/cert/PKIXReason.html" title="enum in java.security.cert">PKIXReason</a></code>, <code><a href="../../java/security/cert/PKIXRevocationChecker.Option.html" title="enum in java.security.cert">PKIXRevocationChecker.Option</a></code>, <code><a href="../../javafx/stage/PopupWindow.AnchorLocation.html" title="enum in javafx.stage">PopupWindow.AnchorLocation</a></code>, <code><a href="../../javafx/geometry/Pos.html" title="enum in javafx.geometry">Pos</a></code>, <code><a href="../../java/nio/file/attribute/PosixFilePermission.html" title="enum in java.nio.file.attribute">PosixFilePermission</a></code>, <code><a href="../../javafx/application/Preloader.StateChangeNotification.Type.html" title="enum in javafx.application">Preloader.StateChangeNotification.Type</a></code>, <code><a href="../../javafx/print/PrintColor.html" title="enum in javafx.print">PrintColor</a></code>, <code><a href="../../javafx/print/Printer.MarginType.html" title="enum in javafx.print">Printer.MarginType</a></code>, <code><a href="../../javafx/print/PrinterJob.JobStatus.html" title="enum in javafx.print">PrinterJob.JobStatus</a></code>, <code><a href="../../javafx/print/PrintQuality.html" title="enum in javafx.print">PrintQuality</a></code>, <code><a href="../../javafx/print/PrintSides.html" title="enum in javafx.print">PrintSides</a></code>, <code><a href="../../javafx/scene/layout/Priority.html" title="enum in javafx.scene.layout">Priority</a></code>, <code><a href="../../java/lang/ProcessBuilder.Redirect.Type.html" title="enum in java.lang">ProcessBuilder.Redirect.Type</a></code>, <code><a href="../../java/net/Proxy.Type.html" title="enum in java.net">Proxy.Type</a></code>, <code><a href="../../java/sql/PseudoColumnUsage.html" title="enum in java.sql">PseudoColumnUsage</a></code>, <code><a href="../../java/awt/desktop/QuitStrategy.html" title="enum in java.awt.desktop">QuitStrategy</a></code>, <code><a href="../../javax/naming/ldap/Rdn.html" title="class in javax.naming.ldap">Rdn</a></code>, <code><a href="../../jdk/jfr/RecordingState.html" title="enum in jdk.jfr">RecordingState</a></code>, <code><a href="../../java/time/format/ResolverStyle.html" title="enum in java.time.format">ResolverStyle</a></code>, <code><a href="../../javax/annotation/Resource.AuthenticationType.html" title="enum in javax.annotation">Resource.AuthenticationType</a></code>, <code><a href="../../jdk/management/resource/ResourceAccuracy.html" title="enum in jdk.management.resource">ResourceAccuracy</a></code>, <code><a href="../../java/lang/annotation/RetentionPolicy.html" title="enum in java.lang.annotation">RetentionPolicy</a></code>, <code><a href="../../java/math/RoundingMode.html" title="enum in java.math">RoundingMode</a></code>, <code><a href="../../javax/swing/RowFilter.ComparisonType.html" title="enum in javax.swing">RowFilter.ComparisonType</a></code>, <code><a href="../../java/sql/RowIdLifetime.html" title="enum in java.sql">RowIdLifetime</a></code>, <code><a href="../../javax/swing/event/RowSorterEvent.Type.html" title="enum in javax.swing.event">RowSorterEvent.Type</a></code>, <code><a href="../../java/lang/Runtime.Version.html" title="class in java.lang">Runtime.Version</a></code>, <code><a href="../../javafx/scene/input/ScrollEvent.HorizontalTextScrollUnits.html" title="enum in javafx.scene.input">ScrollEvent.HorizontalTextScrollUnits</a></code>, <code><a href="../../javafx/scene/input/ScrollEvent.VerticalTextScrollUnits.html" title="enum in javafx.scene.input">ScrollEvent.VerticalTextScrollUnits</a></code>, <code><a href="../../javafx/scene/control/ScrollPane.ScrollBarPolicy.html" title="enum in javafx.scene.control">ScrollPane.ScrollBarPolicy</a></code>, <code><a href="../../javafx/scene/control/SelectionMode.html" title="enum in javafx.scene.control">SelectionMode</a></code>, <code><a href="../../javax/xml/ws/Service.Mode.html" title="enum in javax.xml.ws">Service.Mode</a></code>, <code><a href="../../java/lang/Short.html" title="class in java.lang">Short</a></code>, <code><a href="../../java/nio/ShortBuffer.html" title="class in java.nio">ShortBuffer</a></code>, <code><a href="../../javafx/geometry/Side.html" title="enum in javafx.geometry">Side</a></code>, <code><a href="../../java/time/format/SignStyle.html" title="enum in java.time.format">SignStyle</a></code>, <code><a href="../../javafx/css/SizeUnits.html" title="enum in javafx.css">SizeUnits</a></code>, <code><a href="../../jdk/jshell/Snippet.Kind.html" title="enum in jdk.jshell">Snippet.Kind</a></code>, <code><a href="../../jdk/jshell/Snippet.Status.html" title="enum in jdk.jshell">Snippet.Status</a></code>, <code><a href="../../jdk/jshell/Snippet.SubKind.html" title="enum in jdk.jshell">Snippet.SubKind</a></code>, <code><a href="../../javax/jws/soap/SOAPBinding.ParameterStyle.html" title="enum in javax.jws.soap">SOAPBinding.ParameterStyle</a></code>, <code><a href="../../javax/jws/soap/SOAPBinding.Style.html" title="enum in javax.jws.soap">SOAPBinding.Style</a></code>, <code><a href="../../javax/jws/soap/SOAPBinding.Use.html" title="enum in javax.jws.soap">SOAPBinding.Use</a></code>, <code><a href="../../jdk/net/SocketFlow.Status.html" title="enum in jdk.net">SocketFlow.Status</a></code>, <code><a href="../../javax/swing/SortOrder.html" title="enum in javax.swing">SortOrder</a></code>, <code><a href="../../jdk/jshell/SourceCodeAnalysis.Completeness.html" title="enum in jdk.jshell">SourceCodeAnalysis.Completeness</a></code>, <code><a href="../../javax/lang/model/SourceVersion.html" title="enum in javax.lang.model">SourceVersion</a></code>, <code><a href="../../javax/net/ssl/SSLEngineResult.HandshakeStatus.html" title="enum in javax.net.ssl">SSLEngineResult.HandshakeStatus</a></code>, <code><a href="../../javax/net/ssl/SSLEngineResult.Status.html" title="enum in javax.net.ssl">SSLEngineResult.Status</a></code>, <code><a href="../../java/lang/StackWalker.Option.html" title="enum in java.lang">StackWalker.Option</a></code>, <code><a href="../../javafx/stage/StageStyle.html" title="enum in javafx.stage">StageStyle</a></code>, <code><a href="../../java/nio/file/StandardCopyOption.html" title="enum in java.nio.file">StandardCopyOption</a></code>, <code><a href="../../javax/tools/StandardLocation.html" title="enum in javax.tools">StandardLocation</a></code>, <code><a href="../../jdk/dynalink/StandardNamespace.html" title="enum in jdk.dynalink">StandardNamespace</a></code>, <code><a href="../../java/nio/file/StandardOpenOption.html" title="enum in java.nio.file">StandardOpenOption</a></code>, <code><a href="../../jdk/dynalink/StandardOperation.html" title="enum in jdk.dynalink">StandardOperation</a></code>, <code><a href="../../java/net/StandardProtocolFamily.html" title="enum in java.net">StandardProtocolFamily</a></code>, <code><a href="../../java/lang/String.html" title="class in java.lang">String</a></code>, <code><a href="../../javafx/scene/shape/StrokeLineCap.html" title="enum in javafx.scene.shape">StrokeLineCap</a></code>, <code><a href="../../javafx/scene/shape/StrokeLineJoin.html" title="enum in javafx.scene.shape">StrokeLineJoin</a></code>, <code><a href="../../javafx/scene/shape/StrokeType.html" title="enum in javafx.scene.shape">StrokeType</a></code>, <code><a href="../../javafx/css/StyleOrigin.html" title="enum in javafx.css">StyleOrigin</a></code>, <code><a href="../../javax/swing/SwingWorker.StateValue.html" title="enum in javax.swing">SwingWorker.StateValue</a></code>, <code><a href="../../java/lang/System.Logger.Level.html" title="enum in java.lang">System.Logger.Level</a></code>, <code><a href="../../javafx/scene/control/TableColumn.SortType.html" title="enum in javafx.scene.control">TableColumn.SortType</a></code>, <code><a href="../../javafx/scene/control/TabPane.TabClosingPolicy.html" title="enum in javafx.scene.control">TabPane.TabClosingPolicy</a></code>, <code><a href="../../javafx/scene/control/TabPane.TabDragPolicy.html" title="enum in javafx.scene.control">TabPane.TabDragPolicy</a></code>, <code><a href="../../jdk/javadoc/doclet/Taglet.Location.html" title="enum in jdk.javadoc.doclet">Taglet.Location</a></code>, <code><a href="../../java/awt/Taskbar.Feature.html" title="enum in java.awt">Taskbar.Feature</a></code>, <code><a href="../../java/awt/Taskbar.State.html" title="enum in java.awt">Taskbar.State</a></code>, <code><a href="../../com/sun/source/util/TaskEvent.Kind.html" title="enum in com.sun.source.util">TaskEvent.Kind</a></code>, <code><a href="../../javafx/scene/text/TextAlignment.html" title="enum in javafx.scene.text">TextAlignment</a></code>, <code><a href="../../javafx/scene/text/TextBoundsType.html" title="enum in javafx.scene.text">TextBoundsType</a></code>, <code><a href="../../javafx/scene/control/skin/TextInputControlSkin.Direction.html" title="enum in javafx.scene.control.skin">TextInputControlSkin.Direction</a></code>, <code><a href="../../javafx/scene/control/skin/TextInputControlSkin.TextUnit.html" title="enum in javafx.scene.control.skin">TextInputControlSkin.TextUnit</a></code>, <code><a href="../../java/time/format/TextStyle.html" title="enum in java.time.format">TextStyle</a></code>, <code><a href="../../java/time/chrono/ThaiBuddhistChronology.html" title="class in java.time.chrono">ThaiBuddhistChronology</a></code>, <code><a href="../../java/time/chrono/ThaiBuddhistDate.html" title="class in java.time.chrono">ThaiBuddhistDate</a></code>, <code><a href="../../java/time/chrono/ThaiBuddhistEra.html" title="enum in java.time.chrono">ThaiBuddhistEra</a></code>, <code><a href="../../java/lang/Thread.State.html" title="enum in java.lang">Thread.State</a></code>, <code><a href="../../java/sql/Time.html" title="class in java.sql">Time</a></code>, <code><a href="../../java/sql/Timestamp.html" title="class in java.sql">Timestamp</a></code>, <code><a href="../../java/util/concurrent/TimeUnit.html" title="enum in java.util.concurrent">TimeUnit</a></code>, <code><a href="../../javafx/scene/input/TouchPoint.State.html" title="enum in javafx.scene.input">TouchPoint.State</a></code>, <code><a href="../../javafx/scene/input/TransferMode.html" title="enum in javafx.scene.input">TransferMode</a></code>, <code><a href="../../java/awt/TrayIcon.MessageType.html" title="enum in java.awt">TrayIcon.MessageType</a></code>, <code><a href="../../com/sun/source/tree/Tree.Kind.html" title="enum in com.sun.source.tree">Tree.Kind</a></code>, <code><a href="../../jdk/nashorn/api/tree/Tree.Kind.html" title="enum in jdk.nashorn.api.tree">Tree.Kind</a></code>, <code><a href="../../javafx/scene/control/TreeSortMode.html" title="enum in javafx.scene.control">TreeSortMode</a></code>, <code><a href="../../javafx/scene/control/TreeTableColumn.SortType.html" title="enum in javafx.scene.control">TreeTableColumn.SortType</a></code>, <code><a href="../../javax/lang/model/type/TypeKind.html" title="enum in javax.lang.model.type">TypeKind</a></code>, <code><a href="../../java/net/URI.html" title="class in java.net">URI</a></code>, <code><a href="../../java/awt/desktop/UserSessionEvent.Reason.html" title="enum in java.awt.desktop">UserSessionEvent.Reason</a></code>, <code><a href="../../java/util/UUID.html" title="class in java.util">UUID</a></code>, <code><a href="../../java/lang/invoke/VarHandle.AccessMode.html" title="enum in java.lang.invoke">VarHandle.AccessMode</a></code>, <code><a href="../../javafx/geometry/VerticalDirection.html" title="enum in javafx.geometry">VerticalDirection</a></code>, <code><a href="../../com/sun/management/VMOption.Origin.html" title="enum in com.sun.management">VMOption.Origin</a></code>, <code><a href="../../javafx/geometry/VPos.html" title="enum in javafx.geometry">VPos</a></code>, <code><a href="../../javax/jws/WebParam.Mode.html" title="enum in javax.jws">WebParam.Mode</a></code>, <code><a href="../../jdk/incubator/http/WebSocket.MessagePart.html" title="enum in jdk.incubator.http">WebSocket.MessagePart</a></code>, <code><a href="../../java/awt/Window.Type.html" title="enum in java.awt">Window.Type</a></code>, <code><a href="../../javafx/concurrent/Worker.State.html" title="enum in javafx.concurrent">Worker.State</a></code>, <code><a href="../../javax/xml/bind/annotation/XmlAccessOrder.html" title="enum in javax.xml.bind.annotation">XmlAccessOrder</a></code>, <code><a href="../../javax/xml/bind/annotation/XmlAccessType.html" title="enum in javax.xml.bind.annotation">XmlAccessType</a></code>, <code><a href="../../javax/xml/bind/annotation/XmlNsForm.html" title="enum in javax.xml.bind.annotation">XmlNsForm</a></code>, <code><a href="../../javax/xml/xpath/XPathEvaluationResult.XPathResultType.html" title="enum in javax.xml.xpath">XPathEvaluationResult.XPathResultType</a></code>, <code><a href="../../java/time/Year.html" title="class in java.time">Year</a></code>, <code><a href="../../java/time/YearMonth.html" title="class in java.time">YearMonth</a></code>, <code><a href="../../java/time/ZonedDateTime.html" title="class in java.time">ZonedDateTime</a></code>, <code><a href="../../java/time/ZoneOffset.html" title="class in java.time">ZoneOffset</a></code>, <code><a href="../../java/time/zone/ZoneOffsetTransition.html" title="class in java.time.zone">ZoneOffsetTransition</a></code>, <code><a href="../../java/time/zone/ZoneOffsetTransitionRule.TimeDefinition.html" title="enum in java.time.zone">ZoneOffsetTransitionRule.TimeDefinition</a></code></dd> </dl> <hr> <pre>public interface <span class="typeNameLabel">Comparable<T></span></pre> <div class="block">This interface imposes a total ordering on the objects of each class that implements it. This ordering is referred to as the class's <i>natural ordering</i>, and the class's <code>compareTo</code> method is referred to as its <i>natural comparison method</i>.<p> Lists (and arrays) of objects that implement this interface can be sorted automatically by <a href="../../java/util/Collections.html#sort(java.util.List)"><code>Collections.sort</code></a> (and <a href="../../java/util/Arrays.html#sort(java.lang.Object%5B%5D)"><code>Arrays.sort</code></a>). Objects that implement this interface can be used as keys in a <a href="../../java/util/SortedMap.html" title="interface in java.util">sorted map</a> or as elements in a <a href="../../java/util/SortedSet.html" title="interface in java.util">sorted set</a>, without the need to specify a <a href="../../java/util/Comparator.html" title="interface in java.util">comparator</a>.<p> The natural ordering for a class <code>C</code> is said to be <i>consistent with equals</i> if and only if <code>e1.compareTo(e2) == 0</code> has the same boolean value as <code>e1.equals(e2)</code> for every <code>e1</code> and <code>e2</code> of class <code>C</code>. Note that <code>null</code> is not an instance of any class, and <code>e.compareTo(null)</code> should throw a <code>NullPointerException</code> even though <code>e.equals(null)</code> returns <code>false</code>.<p> It is strongly recommended (though not required) that natural orderings be consistent with equals. This is so because sorted sets (and sorted maps) without explicit comparators behave "strangely" when they are used with elements (or keys) whose natural ordering is inconsistent with equals. In particular, such a sorted set (or sorted map) violates the general contract for set (or map), which is defined in terms of the <code>equals</code> method.<p> For example, if one adds two keys <code>a</code> and <code>b</code> such that <code>(!a.equals(b) && a.compareTo(b) == 0)</code> to a sorted set that does not use an explicit comparator, the second <code>add</code> operation returns false (and the size of the sorted set does not increase) because <code>a</code> and <code>b</code> are equivalent from the sorted set's perspective.<p> Virtually all Java core classes that implement <code>Comparable</code> have natural orderings that are consistent with equals. One exception is <code>java.math.BigDecimal</code>, whose natural ordering equates <code>BigDecimal</code> objects with equal values and different precisions (such as 4.0 and 4.00).<p> For the mathematically inclined, the <i>relation</i> that defines the natural ordering on a given class C is:<pre><code> {(x, y) such that x.compareTo(y) <= 0}. </code></pre> The <i>quotient</i> for this total order is: <pre><code> {(x, y) such that x.compareTo(y) == 0}. </code></pre> It follows immediately from the contract for <code>compareTo</code> that the quotient is an <i>equivalence relation</i> on <code>C</code>, and that the natural ordering is a <i>total order</i> on <code>C</code>. When we say that a class's natural ordering is <i>consistent with equals</i>, we mean that the quotient for the natural ordering is the equivalence relation defined by the class's <a href="../../java/lang/Object.html#equals(java.lang.Object)"><code>equals(Object)</code></a> method:<pre> {(x, y) such that x.equals(y)}. </pre><p> This interface is a member of the <a href="../../java/util/package-summary.html#CollectionsFramework"> Java Collections Framework</a>.</div> <dl> <dt><span class="simpleTagLabel">Since:</span></dt> <dd>1.2</dd> <dt><span class="seeLabel">See Also:</span></dt> <dd><a href="../../java/util/Comparator.html" title="interface in java.util"><code>Comparator</code></a></dd> </dl> </li> </ul> </div> <div class="summary"> <ul class="blockList"> <li class="blockList"> <!-- ========== METHOD SUMMARY =========== --> <section role="region"> <ul class="blockList"> <li class="blockList"><a id="method.summary"> <!-- --> </a> <h3>Method Summary</h3> <table class="memberSummary"> <caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd"> </span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd"> </span></span><span id="t3" class="tableTab"><span><a href="javascript:show(4);">Abstract Methods</a></span><span class="tabEnd"> </span></span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colSecond" scope="col">Method</th> <th class="colLast" scope="col">Description</th> </tr> <tr id="i0" class="altColor"> <td class="colFirst"><code>int</code></td> <th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="../../java/lang/Comparable.html#compareTo(T)">compareTo</a></span>​(<a href="../../java/lang/Comparable.html" title="type parameter in Comparable">T</a> o)</code></th> <td class="colLast"> <div class="block">Compares this object with the specified object for order.</div> </td> </tr> </table> </li> </ul> </section> </li> </ul> </div> <div class="details"> <ul class="blockList"> <li class="blockList"> <!-- ============ METHOD DETAIL ========== --> <section role="region"> <ul class="blockList"> <li class="blockList"><a id="method.detail"> <!-- --> </a> <h3>Method Detail</h3> <a id="compareTo(java.lang.Object)"> <!-- --> </a><a id="compareTo(T)"> <!-- --> </a> <ul class="blockListLast"> <li class="blockList"> <h4>compareTo</h4> <pre>int compareTo​(<a href="../../java/lang/Comparable.html" title="type parameter in Comparable">T</a> o)</pre> <div class="block">Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. <p>The implementor must ensure <code>sgn(x.compareTo(y)) == -sgn(y.compareTo(x))</code> for all <code>x</code> and <code>y</code>. (This implies that <code>x.compareTo(y)</code> must throw an exception iff <code>y.compareTo(x)</code> throws an exception.) <p>The implementor must also ensure that the relation is transitive: <code>(x.compareTo(y) > 0 && y.compareTo(z) > 0)</code> implies <code>x.compareTo(z) > 0</code>. <p>Finally, the implementor must ensure that <code>x.compareTo(y)==0</code> implies that <code>sgn(x.compareTo(z)) == sgn(y.compareTo(z))</code>, for all <code>z</code>. <p>It is strongly recommended, but <i>not</i> strictly required that <code>(x.compareTo(y)==0) == (x.equals(y))</code>. Generally speaking, any class that implements the <code>Comparable</code> interface and violates this condition should clearly indicate this fact. The recommended language is "Note: this class has a natural ordering that is inconsistent with equals." <p>In the foregoing description, the notation <code>sgn(</code><i>expression</i><code>)</code> designates the mathematical <i>signum</i> function, which is defined to return one of <code>-1</code>, <code>0</code>, or <code>1</code> according to whether the value of <i>expression</i> is negative, zero, or positive, respectively.</div> <dl> <dt><span class="paramLabel">Parameters:</span></dt> <dd><code>o</code> - the object to be compared.</dd> <dt><span class="returnLabel">Returns:</span></dt> <dd>a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.</dd> <dt><span class="throwsLabel">Throws:</span></dt> <dd><code><a href="../../java/lang/NullPointerException.html" title="class in java.lang">NullPointerException</a></code> - if the specified object is null</dd> <dd><code><a href="../../java/lang/ClassCastException.html" title="class in java.lang">ClassCastException</a></code> - if the specified object's type prevents it from being compared to this object.</dd> </dl> </li> </ul> </li> </ul> </section> </li> </ul> </div> </div> </main> <!-- ========= END OF CLASS DATA ========= --> <footer role="contentinfo"> <nav role="navigation"> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a id="navbar.bottom"> <!-- --> </a> <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> <a id="navbar.bottom.firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../overview-summary.html">Overview</a></li> <li><a href="../../java.base-summary.html">Module</a></li> <li><a href="package-summary.html">Package</a></li> <li class="navBarCell1Rev">Class</li> <li><a href="class-use/Comparable.html">Use</a></li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../deprecated-list.html">Deprecated</a></li> <li><a href="../../index-files/index-1.html">Index</a></li> <li><a href="../../help-doc.html">Help</a></li> </ul> <div class="aboutLanguage"><div style="margin-top: 14px;"><strong>Java SE 10 & JDK 10</strong> </div></div> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../java/lang/CloneNotSupportedException.html" title="class in java.lang"><span class="typeNameLink">Prev Class</span></a></li> <li><a href="../../java/lang/Compiler.html" title="class in java.lang"><span class="typeNameLink">Next Class</span></a></li> </ul> <ul class="navList"> <li><a href="../../index.html?java/lang/Comparable.html" target="_top">Frames</a></li> <li><a href="Comparable.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_bottom"> <li><a href="../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_bottom"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> </div> <div> <ul class="subNavList"> <li>Summary: </li> <li>Nested | </li> <li>Field | </li> <li>Constr | </li> <li><a href="#method.summary">Method</a></li> </ul> <ul class="subNavList"> <li>Detail: </li> <li>Field | </li> <li>Constr | </li> <li><a href="#method.detail">Method</a></li> </ul> </div> <a id="skip.navbar.bottom"> <!-- --> </a></div> <!-- ======== END OF BOTTOM NAVBAR ======= --> </nav> <p class="legalCopy"><small><a href="http://bugreport.java.com/bugreport/">Report a bug or suggest an enhancement</a><br> For further API reference and developer documentation see the <a href="http://www.oracle.com/pls/topic/lookup?ctx=javase10&id=homepage" target="_blank">Java SE Documentation</a>, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.<br> Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.<br> <a href="../../../legal/copyright.html">Copyright</a> © 1993, 2018, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.<br>All rights reserved. Use is subject to <a href="http://www.oracle.com/technetwork/java/javase/terms/license/java10speclicense.html">license terms</a> and the <a href="http://www.oracle.com/technetwork/java/redist-137594.html">documentation redistribution policy</a>. <!-- Version 10+46 --></small></p> </footer> <!-- Start SiteCatalyst code --> <script type="application/javascript" src="https://www.oracleimg.com/us/assets/metrics/ora_docs.js"></script> <!-- End SiteCatalyst code --> <noscript> <p>Scripting on this page tracks web page traffic, but does not change the content in any way.</p> </noscript> </body> </html>