?? overloadedconstructors.java
字號:
// initialization/OverloadedConstructors.java
// TIJ4 Chapter Initialization, Exercise 9, page 172
// Create a class with two (overloaded) constructors. Using 'this', call
// the second constructor from inside the first one.
class Doc {
Doc(int i) {
this("MD");
int yearsTraining = i;
System.out.println("New doc with " + i + " years of training");
}
Doc(String s) {
String degree = s;
System.out.println("New doc with " + s + " degree");
}
void intubate() {
System.out.println("prepare patient");
laryngoscopy();
}
void laryngoscopy() {
System.out.println("use laryngoscope");
}
}
public class OverloadedConstructors {
public static void main(String[] args) {
new Doc(8).intubate();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -