What about int i, should'nt we say that it needs to be garbage collected too ?.
Originally posted by Mike Gershman:
"int i" is a primitive local variable, not an object.
It is allocated on the stack, not the heap, and it goes away when doSomething() finishes. primitive local variables are never garbage collected because they are not on the heap.
Once a variable is no longer referenced by anything it is available for garbage collection.