Recently, I learned that the static variable could be accessed from an object, in addition to a class name.
I believe that static variables reside in the permanent generation area in the heap, not in the object related area in the heap.
Also, I think that m1.count refers the memory position of m1, and add some offset to access the count instance variable.
In my logic, m1.count should spit error since there is no instance variable called count near m1 object in memory.
How could it be possible? I want to know how it works in memory. Here is the code:
class Member{
public static int count;
}
public static void main(){
Member m1 = new Member();
System.out.println(m1.count); // ???
}