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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!