I have read many articles on Garbage Collection in Java, some of
them are too complex to understand and some of them don’t
contain enough information required to understand garbage
collection in Java. Then I decided to write my own experience as
an article or you call tutorial about How Garbage Collection
works in Java or what is Garbage collection in Java in simple
word which would be easy to understand and have sufficient
information to understand how garbage collection works in Java.
This article is in continuation of my previous articles How
Classpath works in Java and How to write Equals method in java
and before moving ahead let's recall few important points about
garbage collection in java: 1) objects are created on heap in
Java irrespective of there scope e.g. local or member variable.
while its worth noting that class variables or static members
are created in method area of Java memory space and both heap
and method area is shared between different thread. 2) Garbage
collection is a mechanism provid