+ 1
How does a class actually function in java??
Like in c++, we need to create an object of the class, but it's not the case in Java, so how does it functions on the basic level.
1 Odpowiedź
+ 8
If you create objects, every object and the fields/methods have it's own space in memory and the reference to the object is stored in the variable that holds the object (like a pointer in c++, but more like a hidden pointer).
So you will find objecta.somefield and objectb.somefield of the same class in memory.
A static field/method of a class has only one address/space in memory, which is referenced by the class (reflection). You'll find the differences between static and dynamic references on this site:
https://www.sitesbay.com/java/java-static-and-non-static-method