0
static in class level
Can anyone say about static un class level
1 Answer
+ 3
In Java, if something is static at the class level then it is a class variable. Unlike instance variables, which require instantiation to access the variable, class variables are accessed through the class itself.
Person p = new Person();
p.age = 25; // <- age is instance variable
Person.num_people++; //<- num_people is class variable
p.num_people++; //<- CANNOT DO THIS
Class variables are static, this there is only one reference across all instances.