For some reason my LinkedList addObj() method is adding the first object in the list twice -


for reason linkedlist addobj() method adding first object in list twice

here method

public <t> void addobj(t obj) {         if(head == null)         head = new node(obj, null);      node t = head;     while(t.next != null)         t = t.next;      t.next = new node (obj,null);  } 

the output dispays

obj1
obj1
obj2
obj3
obj4


Comments

Popular posts from this blog

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

javascript - Confirm a form & display message if form is valid with JQuery -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -