I have two classes one is:
public class Emp {
String name;
static int bankVault;
}
and the other one is:
public class TestEmp {
public static void main(String[] args) {
Emp emp1 = new Emp();
Emp emp2 = new Emp();
emp1.bankVault = 10;
emp2.bankVault = 20;
System.out.println(emp1.bankVault);
System.out.println(emp2.bankVault);
System.out.println(Emp.bankVault);
}
}
The output is:
20
20
20
Is this because of the static
word? Shouldn't the first System.out.println
return 10?