public interface Comparable<T> {
public int compareTo(T o);
}
1. 接口(Comparable:可比较接口)
public static boolean less(Comparable v, Comparable w) {
return v.compareTo(w) < 0;
}
- 当然也可以将参数中的 Comparable 具化为
Comparable<Character>
,
public final class Character implements Comparable<Character>