变量的作用域
代码如下:
package Day06;
public class ClassP {
private int x = 0;//实例变量
private int y = 0;
public void p(){
int x = 1;//局部变量
System.out.println(x);
System.out.println(y);
}
public void q(){
System.out.println(x);
}
}
二部分
package Day06;
public class TestClassP {
public static void main(String[] args) {
ClassP pClass = new ClassP();
pClass.p();
pClass.q();
}
}