⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 overloadedconstructors.java

📁 JAVA编程思想第四版英文原版习题答案. pdf原版的
💻 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 + -