java - Singly Linked List Delete Value -
i making singly linked list need put delete method getting error help?
public void remove(int index) { getnode(index - 1).next = getnode(index + 1); }
many possible errors can happen here. one, definitively put more verification before making changes if
- are on first element (then header 2nd element);
- are on last element (then getnode(index+1) returning correctly null or throwing exception)?
Comments
Post a Comment