📄 scopetest.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 + -