?? ex17.java
字號:
// interfaces/Ex17.java
// TIJ4 Chapter Interfaces, Exercise 17, page 335
// Prove that the fields in an interface are implicitly static and final.
interface Days {
int SUNDAY = 1, MONDAY = 2, TUESDAY = 3, WEDNESDAY = 4,
THURSDAY = 5, FRIDAY = 6, SATURDAY = 7;
}
class Week implements Days {
private static int count = 0;
private int id = count++;
public Week() { System.out.println("Week() " + id); }
}
public class Ex17 {
public static void main(String[] args) {
// Without any objects, static fields exist:
System.out.println("SUNDAY = " + Days.SUNDAY);
System.out.println("MONDAY = " + Days.MONDAY);
Week w0 = new Week();
Week w1 = new Week();
// Error: cannot assign a value to final variable SUNDAY:
// w.SUNDAY = 2;
// Error: cannot assign a value to final variable MONDAY:
// w1.MONDAY = w0.MONDAY;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -