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

📄 scopetest.java

📁 实验 1 对象的创建和使用 ( l )理解类的定义; ( 2 )掌握对象的声明; ( 3 )学会使用构造函数初始化对象; ( 4 )使用类的数据和方法。 实验 2 类的静态成员与实例成员
💻 JAVA
字号:
//ScopeTest.java
class ScopeTest {
	int x;

	static int m = 0;

	void show() {
		int x = 8, y;
		for (y = 0; y < 2; y++) {
			int v = 5;
			System.out.println("z=" + v);
			v = 10;
			System.out.println("z=" + v);
			System.out.println("方法域中的X=" + x + "在块内显示");
		}
		// z=20;
		System.out.println("方法域中的X=" + x + "在块外显示");
		System.out.println("类域中的X=" + this.x + "在块外显示");
		System.out.println("类域中的m=" + this.m + "在块外显示");
	}

	void setx(int x) {
		this.x = x;
	}

	void setm(int m) {
		this.m = m;
	}

	public static void main(String[] args) {
		ScopeTest application = new ScopeTest();
		application.setx(2);
		application.setm(3);
		application.show();
	}
}

⌨️ 快捷键说明

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