0

Static fields and methods are allocated memory once only, when they are first referenced, irrespective of the no. of objects u later create. But, memory is allocated for its data members each time an object is created. But what about the non-static methods, they don't change for each object. So are they allocated memory once for all objects or once for each object ?

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by JamesCherrill
0

Methods, both static and instance, are loaded into the VM when the class is loaded. Only one copy of each method is loaded and held in memory.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.