Deleting Elements from List

View previous topic View next topic Go down

Deleting Elements from List

Post  Admin on Fri Aug 26, 2011 12:20 pm

public boolean delete(ListNode head, Object a){
ListNode element=head;
if(element==null)
return false;
if(element.equals(a)){
head=element.next;
return true;
}
else{
while(element){
if(element.next.equals(a)){
element.next=a.next;
return true;
}
element=element.next;
}
return false;
}
}

Admin
Admin

Posts : 131
Join date : 2011-08-16

View user profile http://codefornongeek.forumotion.com

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum