Reference:Java.lang.Comparable
From Triled Wiki
java.lang
public interface java.lang.Comparable
| java.lang.Comparable |
This interface should be implemented by all classes which wish to define anatural ordering of their instances. The ordering rule must be transitive and invertable (i.e. the sign of the result of x.compareTo(y) must equal the negation of the sign of the result of y.compareTo(x) for all x and y).
In addition, it is desireable (but not required) that when the result of x.compareTo(y) is zero (and only then) the result of x.equals(y) should be true.Contents |
[edit] Known Indirect Subclasses
Adapter.Mode, Authenticator.RequestorType, BigDecimal, BigInteger, Bitmap.CompressFormat, Bitmap.Config, BlurMaskFilter.Blur, Boolean, Byte, ByteBuffer, Calendar, Canvas.EdgeType, CharBuffer, Character, Charset, CollationKey, Connection.State, Date, Delayed, Double, DoubleBuffer, ElementType, Enum, File, Float, FloatBuffer, Formatter.BigDecimalLayoutForm, GradientDrawable.Orientation, GregorianCalendar, ImageView.ScaleType, IntBuffer, Integer, Interpolator.Result, KeyRep.Type, Layout.Alignment, Long, LongBuffer, MapView.DeviceType, MapView.ReticleDrawMode, MappedByteBuffer, Matrix.ScaleToFit, ObjectStreamField, Paint.Align, Paint.Cap, Paint.Join, Paint.Style, Path.Direction, Path.FillType, PathDashPathEffect.Style, PorterDuff.Mode, Proxy.Type, Region.Op, RetentionPolicy, RoundingMode, SSLEngineResult.HandshakeStatus, SSLEngineResult.Status, ScheduledFuture, ServiceState.State, Shader.TileMode, Short, ShortBuffer, SmsMessage.MessageClass, String, TelephoneNumberUtil.Flags, TextInputMethod.Capitalize, TextUtils.TruncateAt, TextView.BufferType, Thread.State, Time, TimeUnit, Timestamp, URI, UUID, Uri, WebSettings.LayoutAlgorithm, WebSettings.TextSize, Xml.Encoding
[edit] Summary
[edit] Public Methods
| int | compareTo (T another) | ||||
| Answers an integer indicating the relative positions of the receiver and the argument in the natural order of elements of the receiver's class. | |||||
[edit] Details
[edit] Public Methods
[edit] public int compareTo(T another)
Answers an integer indicating the relative positions of the receiver and the argument in the natural order of elements of the receiver's class.
Parameters
| another | Object an object to compare the receiver to |
|---|
Returns
- int which should be <0 if the receiver should sort before the argument, 0 if the receiver should sort in the same position as the argument, and >0 if the receiver should sort after the argument.
Throws
| ClassCastException | if the argument can not be converted into something comparable with the receiver. |
|---|
[edit] References
- Original documentation page for Android SDK build m5-rc15e - 14 apr 2008 17:27
