Originally posted by pooja jain:
a is not object . a is pointing to an object & that object I am creating in a method scope . so after method , how it can be live ?
Yes, technically, a is not the object. But it is a reference to an object. That reference is declared
outside the method.
So even though you've created an object inside the method, you've assigned it to a reference that was created outside the method. As long as that reference is in scope, the object to which it points will not be eligible for garbage collection.
- Jeff