Does every object has its own copies of non static methods in memory??
Printable View
Does every object has its own copies of non static methods in memory??
Can u give me some more explanation sir i am just a newbie:(
I mean if we have created 10 objects of any class then methods(whether static or non static) will have comman copy in memory and all objects would share them .....am i right? :(
This is a link to a course by stanford. It is called cs106a. Follow it completly and do the assignments. Then follow the course cs106b, also on youtube. Then cs107. About halfway through cs107 you will understand exactly how objects work under the hood. Good luck!
Yes, all the objects will share the same method byte code. When methods are called though, parameters and local variables will be pushed onto the stack, so memory will be temporarily used during a method's run.
For more on methods and memory, check Google. One hit it gave me was this:
memory-allocation-methods-java
@imorio Thanks sir...I wish this will help me...:)
If you're a newbie, why on earth do you need to know whether objects of the same class share a single method copy in memory?