Firstly, the program used a doubly linked-list which contains ID and NAME lists. Both ID and NAME are parallel. For example, Tony 2456, David 3749, Jessica 9743 and so on.
So I created a method; its function is to remove a specific ID by user input, then it should remove the node which includes both ID and name. Here is my code which seems incorrect. Suggestions?
public static void removeTarget(int IDtarget){
Node IDfirst = head.IDlink;
Node IDsecond = head;
Node NAMEfirst = head.NAMElink;
Node NAMEsecond = head;
String NAME;
if(IDfirst == null || target != IDfirst.id) {
return;
}
else {
NAME = NAMEfirst.name;
IDsecond = IDfirst;
remove(IDsecond.id);
}
if(NAME != null) {
NAMEfirst = NAMEsecond;
remove(NAME);
}
}