foreach loop on ArrayList<Stack<String>>
I have decided to take it one small step at a time. Here's the code giving me errors:
for(Stack<String> s : paths)
if(s.peek() == n.getName())
// Adding the stacked path [p] to the safe paths list [paths]
// Now that the stacked path [p] has been stored, we need to clear, empty [p] for the next path.
Right before the foreach loop executes I check paths (through debugger), and I can see that it does contain something. Yet I'm getting the error:
private ArrayList<Stack<String>> paths = new ArrayList<Stack<String>>();
I googled online how to do a Java foreach loop, and I can't see anything wrong with the Syntax. Indeed Eclipse doesn't complain about the syntax. ! What am I doing wrong ?
No Exception Message - java.util.EmptyStackException
PS. I believe you don't need to know what the variable [p] is because the code never gets to it.