Nikita Dutt wrote:Hi All,
Have a small question where do reference variable at the class level gets stored ; for example
Hope i make sense ; thanks in advance
Regards
At line 12, you are creating the instance variable/field , Which is the reference variable, declaration and initialization ,of class MyClass
When you will create the instance of the
,then that instance will be stored on Heap memory along with all its instance variables/fields i.e. the state of the object
So, reference variable cL will be on heap as along as instance is on heap
and yes reference variable c2 which is declared inside method will be live as long as method code executes.
Hope this helps..