Question: Using our LinkedListStack.java project file, modify the popAll() method to return all of the integer values that are popped from the stack. Submit just the
Using our LinkedListStack.java project file, modify the popAll() method to return all of the integer values that are popped from the stack.
Submit just the popAll() method.
public int pop() throws LinkedListEmptyException{
if(head == null){
throw new LinkedListEmptyException();
}
--count;
int value = head.data;
head = head.next;
return value;
}
/**
* Remove all elements of the stack
* TODO: return the value popped
**/
public void popAll() throws LinkedListEmptyException{
if(head == null){
throw new LinkedListEmptyException();
}
head = null;
count = 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
