We usually think that reference types are stored on the Head, right. Yes we are right.
But we do think that value types are stored on Stack and here we are always not right.
Only local variables are stored in the stack, so what's this local variables? Local variables declared within methods and method parameters live on stack. So when on heap? If they are declared within the class. Value types lives on wherever they are declared. So if they are created in reference type ex, class they would be stored on heap, and if declared locally ex. within method then stack.
No comments:
Post a Comment