接口用来描述类具有什么功能。 public interface Comparable { int compareTo(Object other); } Employee 类实现 Comparable 接口 class Employee implements Comparable<Employee> { public int compareTo(Employee other) { return Double.compare(salary, other.salary); } }