In java, garbage means unreferenced objects.
Garbage Collection is process of reclaiming the runtime unused memory
automatically.The Garbage collector of JVM collects only those objects that are
created by new keyword. So if you have created any object without new, you can
use finalize method to perform cleanup processing (destroying remaining
objects).
Advantage of Garbage Collection:
1 It makes java memory efficient because garbage collector removes the
unreferenced objects from heap memory.
2 It is automatically done by the garbage collector so we don't need to
make extra efforts.