Android
java.lang
public interface

java.lang.Comparable<T>

java.lang.Comparable<T>

This interface should be implemented by all classes which wish to define a natural 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.

Known Indirect Subclasses

Summary

Public Methods

          int  compareTo(T another)
Returns an integer indicating the relative positions of the receiver and the argument in the natural order of elements of the receiver's class.

Details

Public Methods

public int compareTo(T another)

Returns 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.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:48