Reputation: 33
In java, lets say I have executed this code
ClassA classa = new ClassA();
classa = new ClassA();
What will happen to the old object? will it be deleted, or it will stick in memory?
Upvotes: 0
Views: 81
Reputation: 5005
The classa variable will point to the new object ClassA. The old ClassA object will be eligible for Garbage Collection. You can find this behaviour documented in this garbage collector document.
Upvotes: 4