A variable is allocated when the structure containing it is placed.
For a local variable in a method, this (with some caveats) when calling the method.
For a static variable, this is when the class is "initialized" (which occurs some time after its loading and before its first use).
For an instance variable, this is when the instance is created.
source
share