Java Utililty Methods Comparable

List of utility methods to do Comparable

  1. HOME
  2. Java
  3. C
  4. Comparable

Description

The list of methods to do Comparable are organized into topic(s).

Method

int compare(Comparable left, Comparable right)
compare
if (left == null && right == null)
 return 0;
else if (left == null)
 return -1;
else if (right == null)
 return 1;
else
 return left.compareTo(right);
...
int compare(Comparable obj1, T obj2)
compare
if (obj1 == null) {
 if (obj2 == null) {
 return 0;
 } else {
 return 1;
} else {
 return obj1.compareTo(obj2);
...
int compare(final Comparable left, final Comparable right)
Compares to comparable objects -- defending against null.
if (left == null && right == null) {
 return 0;
} else if (left == null) {
 return -1;
} else if (right == null) {
 return 1;
} else {
 return left.compareTo(right);
...

AltStyle によって変換されたページ (->オリジナル) /