what is garbage collection in the context of java?
When you initialize an object, it gets created on the heap (dynamic memory). Now usually you have a variable or an array referencing this object. However, if you don't - maybe you assigned your variable a different object or you removed the object from the array - the object will still exist in the memory, but you can't access it anymore. That's called a memory leak. Java remembers all memory segments it uses and regularly deletes all data that's not referenced anymore in order to free memory. That's called garbage collection.
I guess, it is deleteting unused objects and pointers