我已经定义了一个对象并声明了一个静态变量i
。在该get()
方法中,当我尝试打印实例和类变量时,都打印相同的值。
不是this.i
实例变量吗?它应该打印 0 而不是 50?
public class test {
static int i = 50;
void get(){
System.out.println("Value of i = " + this.i);
System.out.println("Value of static i = " + test.i);
}
public static void main(String[] args){
new test().get();
}
}