public interface Comparable<T>

Known subtypesAdFormat, LlmException.ErrorType, ResponseFormat, Role, InferenceOptions.Accelerator, TensorType, VisionFeature, AnalyticsCapability, ConsentMode, EntityQuery.Kind, AndroidMinSdk, DesktopTitleBar, FileAccess, HardenControlFlow, HardenLevel, HardenStrings, HintKind, InstallLocation, IosDependencyManager, IosProjectType, ThemeMode, Toggle, ProtoField.WireKind, ARAnchorEvent.Kind, ARFaceRegion, ARHitResult.Type, ARPlane.Type, ARPlaneDetection, ARPlaneEvent.Kind, ARTrackingFailureReason, ARTrackingMode, ARTrackingState, BindAttr, AdapterState, BluetoothError, BluetoothPermission, BondState, DeviceType, GattStatus, ConnectionPriority, ConnectionState, ScanMode, AdvertiseMode, TxPowerLevel, CalendarAccess, CalendarAlarm.Method, CalendarAttendee.Response, CalendarAttendee.Role, CalendarAuthorizationStatus, CalendarCapability, CalendarChange.ChangeType, CalendarChange.EntityType, CalendarConflict.Resolution, CalendarError, CalendarEvent.Availability, CalendarEvent.Privacy, CalendarEvent.Status, CalendarInfo.ContentType, CalendarMutationScope, CalendarRecurrenceRule.Frequency, CallAvailability, CallDirection, CallEndReason, CallError, CallHandleType, CallState, CallAudioRoute, CameraFacing, FlashMode, FrameFormat, ScaleType, CarColor, GradientDrawable.Orientation, Paint.Style, DialRenderer.Type, XYMultipleSeriesRenderer.Orientation, XYSeriesRenderer.FillOutsideLine.Type, BarChart.Type, PointStyle, AudioRecorderComponent.RecorderState, AssetDef.Kind, AssetDef.Type, GameLevel.Mode, Layer.Kind, BodyType, Collision.PointState, ContactID, ContactID.Type, Manifold.ManifoldType, TimeOfImpact.TOIOutputState, Pair, ShapeType, BodyType, JointType, LimitState, Material.Type, PrimitiveType, RenderState.BlendMode, RenderState.CullMode, Texture.Filter, Texture.Wrap, VertexAttribute.Usage, AggregateMetric, HealthAggregationStyle, HealthAuthorizationStatus, HealthAvailability, HealthDataKind, HealthError, HealthRequestStatus, HealthUnitDimension, RecordingMethod, SleepStage, SleepStageSupport, WorkoutActivityType, GlucoseRecordFilter.Kind, SensorSessionState, WorkoutEvent.Kind, WorkoutLocationType, WorkoutSessionState, AccessoryCategory, AirQualityLevel, AlarmState, ChargingState, DoorState, FanMode, HeatingCoolingMode, HomeAuthorizationStatus, HomeAvailability, HomeBackend, HomeError, LockState, PositionState, SceneType, ServiceType, StructureChangeKind, TraitUnit, TraitUnitDimension, TraitValueKind, CommissioningStyle, Exposure, IntentParameterType, IntentSource, ConnectionRequest.CachingMode, WebSocketState, WiFiSecurity, TravelMode, MCPVerbosity, AsyncMedia.MediaErrorType, AsyncMedia.State, NearbyAvailability, NearbyError, NearbyPermission, CompanionProfile, RangingRemovalReason, RangingRole, RangingUnit, PayloadStatus, TransportStrategy, NfcError, TagType, NotificationPermissionResult.AuthorizationLevel, SQLMap.SqlType, BiometricError, BiometricType, TapjackingPolicy, FailureMode, SurfaceAlignment, SurfaceFontWeight, WidgetSize, AccessibilityColorVisionDeficiency, BrowserComponent.JSType, MultipleGradientPaint.ColorSpaceType, MultipleGradientPaint.CycleMethod, RichTextComponent.SizeMode, RichTextFormat, TextSelection.TextSelectionTrigger, Toolbar.BackCommandPolicy, AccessibilityCheckedState, AccessibilityGrouping, AccessibilityIssue.Severity, AccessibilityLiveRegion, AccessibilityRole, ActionEvent.Type, WindowEvent.Type, GlassRecipe.Kind, Validator.HighlightMode, Promise.State, VpnError, VpnProtocol, VpnStatus, TunnelStopReason, VREye, Byte, Double, Enum, Float, Integer, Long, Short, String, ElementType, RetentionPolicy, Charset, Duration, Instant, LocalDate, LocalDateTime, LocalTime, OffsetDateTime, ZonedDateTime, Date

This interface should be implemented by all classes that wish to define a natural order of their instances. java.util.Collections#sort and java.util.Arrays#sort can then be used to automatically sort lists of classes that implement this interface.

The order rule must be both transitive (if x.compareTo(y) < 0 and y.compareTo(z) < 0, then x.compareTo(z) < 0 must hold) and invertible (the sign of the result of x.compareTo(y) must be equal to the negation of the sign of the result of y.compareTo(x) for all combinations of x and y).

In addition, it is recommended (but not required) that if and only if the result of x.compareTo(y) is zero, then the result of x.equals(y) should be true.

Methods

public abstract int compareTo(T another)Compares this object to the specified object to determine their relative order.

Method details

compareTo

public abstract int compareTo(T another)
Compares this object to the specified object to determine their relative order.

Parameters

another T
the object to compare to this instance.

Returns

a negative integer if this instance is less than another; a positive integer if this instance is greater than another; 0 if this instance has the same order as another.

Throws

ClassCastException
if another cannot be converted into something comparable to this instance.