Comparable
The Comparable interface determines the natural ordering between objects
of the same type. Comparable defines a generic compareTo(T) method
that returns an integer indicating
whether an object is less than, equal to,
or greater than a comparable object. A list of Comparable objects can
be sorted in the Collections#sort(List) method.
Comparator
The Comparator interface determines a sorting
strategy between objects
of the same type. This can be used to sort objects that do not implement
Comparable
, or to sort objects in a manner distinct from their natural
ordering. Comparator defines a generic compare(T, T) method that
returns an integer indicating whether the first object is less than, equal to,
or greater than the second object. Lists can be
sorted by comparators in the
Collections#sort(List, Comparator)
method.
Runnable
The Runnable interface encapsulates an action that runs inside of a thread.
Runnable
defines a run() method that is invoked
by the thread scheduler
after a thread transitions into a runnable state.
Serializable
The Serializable interface is a marker which
indicates that an object
is eligible for serialization. Serialization is the process of converting an object
into bytes that can be stored on a filesystem or streamed over a network. Objects
can provide custom serialization logic by implementing
three special private
methods: writeObject(), readObject(),
and readObjectNoData(). Every serializable class is assigned
a configurable version number called
serialVersionUID that is used to ensure
compatibility during the deserialization process.