?? explicitstaticex.java
字號:
// initialization/ExplicitStaticEx.java
// TIJ4 Chapter Initialization, Exercise 14, page 191
/* Create class with static String field initialized at point of definition and
* another one initialized by the static block. Add static method that prints
* both fields and demonstrates that they are both initialized before thay are
* used.
*/
import static net.mindview.util.Print.*;
class Go {
static String s1 = "run";
static String s2, s3;
static {
s2 = "drive car";
s3 = "fly plane";
print("s2 & s3 initialized");
}
static void how() {
print(s1 + " or " + s2 + " or " + s3);
}
Go() { print("Go()"); }
}
public class ExplicitStaticEx {
public static void main(String[] args) {
print("Inside main()");
Go.how();
print("Go.s1: " + Go.s1);
}
static Go g1 = new Go();
static Go g2 = new Go();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -