I have defined an object and declared a static variable i
. In the get()
method, when I try to print the instance and class variable, both print the same value.
Isn't this.i
an instance variable? Should it print 0 instead of 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();
}
}