Reputation: 788
Question regarding stack and heap in java
When a static variable, method or class is created in java - where is it stored? Is it stored on the call stack or on the heap?
I mean:
static (inner) classes
static fields
static methods
Upvotes: 0
Views: 101
Reputation: 41281
All non-local things not explicitly stored off-heap are stored on the heap. This includes class definitions, fields, and static fields.
Only local variables (in the scope of a single method, constructor, etc) are on the call stack.
Beyond there this is nastily-implementation-dependent. (Hotspot native code storage, anyone?)
Upvotes: 3