Skip to content

Latest commit

 

History

History
executable file
·
19 lines (16 loc) · 315 Bytes

File metadata and controls

executable file
·
19 lines (16 loc) · 315 Bytes

接口用来描述类具有什么功能。

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);
  }
}