Organizational Research By

Surprising Reserch Topic

how does java garbage collector handle self reference using -'java,garbage-collection'

how does java garbage collector handle self reference  using -'java,garbage-collection'

Hopefully a simple question. Take for instance a Circularly-linked list:

class ListContainer
  private listContainer next;

  public void setNext(listContainer next)
  { = next;

class List
  private listContainer entry;

Now since it's a circularly-linked list, when a single elemnt is added, it has a reference to itself in it's next variable. When deleting the only element in the list, entry is set to null. Is there a need to set to null as well for Garbage Collector to free it's memory or does it handle such self-references automagically?

asked Sep 7, 2015 by rajesh
0 votes

Related Hot Questions

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.