I found the following in the book that I use to learn Java:
The garbage collector only frees memory that is allocated using
Pretty much everything other than primitives and Strings are instantiated with a
new. And you should not be worried about Garbage collection to the extent that you have to set variables to
null to make them eligible. GC has become very intelligent in last few years that we don't have to resort these tricks. e.g. Any orphaned object in heap ( which is not referred by anything) is a GC candidate. If you have your code structured, all method scope objects are GC candidate once the method has finished execution, same with a state variable as soon as the object of the class itself is dereferenced.