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 ?
daudiam -6 Junior Poster
Recommended Answers
Jump to PostMethods, 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.
All 2 Replies
NormR1 563 Posting Sage Team Colleague
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.