1

Do I need to set local variables to null after usage , for garbage collector, to collect those local variables ?

A Stranger
  • 551
  • 2
  • 11
  • It is important for specific situations, like implementing your own collections, etc. In a standart case you should refrain from it. For more information read book "Effective Java" by Joshua Bloch. – ferrerverck Sep 15 '14 at 10:04

2 Answers2

2

No, the garbage collector automatically detects local variables that are no longer used.

micha
  • 47,774
  • 16
  • 73
  • 80
0

No. There is no need to. Local variables aka method variables which places on stack vanishes when we exit the local scope.

Suresh Atta
  • 120,458
  • 37
  • 198
  • 307