i can't figure out why this part of my program won't work, I peek outside the while loop and confirm that the stack is not empty, yet when i try to access it inside the while loop I get this error:
"Exception in thread "main" java.util.EmptyStackException at java.util.Stack.peek(Unknown Source)"
here's the relevant piece of code
String test = list.peek();
System.out.println(test);
while(list.peek() != null)
{
temp = list.pop();
There's more too the while loop but it breaks once list.peek
is called inside the parenthesis, I tried changing it to "while(test != null)
" for test purposes but it breaks once it gets to list.pop()