in case of c we have to do free(data) while deleting a node to free up the memory space occupied by the node manually but in case of java we do not have to do the same.Why and what happens??
Asked
Active
Viewed 162 times
1
-
That's due to the fact that [Java uses a garbage collector](https://stackoverflow.com/questions/3798424/what-is-the-garbage-collector-in-java) – pafau k. Jun 01 '20 at 21:47
2 Answers
0
Java is a garbage collected language. This means freeing of these references is taken care of for you by the language itself. There are other forms of leaks, but for cases where the references to this node are no more, the memory is reclaimed on the next garbage collection.

Rannick
- 598
- 5
- 19
0
when you remove the reference to the node will be eligible for the GC to free the memory , For more information, you can read Java Garbage collection basic Oracle doc

0xh3xa
- 4,801
- 2
- 14
- 28