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

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -