📄 simplename.java
字号:
// (Figure 9.29)public class SimpleName implements Comparable { private String firstName; private String lastName; /** post: firstName == first and lastName == last */ public SimpleName(String first, String last) { firstName = first; lastName = last; } /** post: comparison done alphabetically last name before first */ public int compareTo(Object s) { if ( !(s instanceof SimpleName) ) System.out.println("Cannot compareTo SimpleName to other type"); if ( lastName.compareTo(((SimpleName)s).getLast()) < 0 ) return -1; else if ( lastName.compareTo(((SimpleName)s).getLast()) > 0 ) return 1; else return firstName.compareTo(((SimpleName)s).getFirst()); } public String getFirst() { return firstName; } public String getLast() { return lastName; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -