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

📄 protecteddata.java

📁 JAVA编程思想第四版英文原版习题答案. pdf原版的
💻 JAVA
字号:
// access/ProtectedData.java
// TIJ4 Chapter Access, Exercise 6, page 228
/* Create a class with protected data. Create a second class in the same file with
* a method that manipulates the protected data in the first class.
*/

class SomeData {
	protected int a = 13;
}

class DataChanger {
	static void change(SomeData sd, int i) { sd.a = i; }
}

public class ProtectedData {
	public static void main(String[] args) {
		SomeData x = new SomeData();
		System.out.println(x.a);					
		DataChanger.change(x, 99);
		System.out.println(x.a);		
	}	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -