GC is the process of automatically identifying and deleting objects in the heap that are no longer reachable (no references pointing to them). This prevents manual memory management errors like memory leaks and dangling pointers found in C/C++. The GC runs periodically and can be triggered by memory pressure or explicitly requested (though not guaranteed).
A waiter in a restaurant. When you finish your meal and leave the table (remove the reference), the waiter (GC) eventually comes and clears the plate (frees memory). The waiter only clears plates from abandoned tables, not from tables people are still using.
Can you force the Garbage Collector to run immediately by calling System.gc()? Explain the behavior.