Code
public void listRemove(LinkedList newList)
{
String input;
Scanner scan = new Scanner(System.in);
ListIterator myIterator = newList.listIterator();
displayQueue(newList);
System.out.printf("Type what you would like to remove from the list:");
input = scan.nextLine();
if((myIterator.next()).equals(input))
{
myIterator.remove();
}
while(myIterator.hasNext())
{
System.out.print( " "+myIterator.next()+" " );
}
}
.remove is taking out the last element .next returned which always seems to be the first element in the list. I need to be able to input what element I want removed and it remove all of them from the list. Any help appreciated.
/edit
I meant List Iterator, not linked list.
This post was edited by ROM on Oct 23 2015 07:36am