9 Stack limitations/idioms Remember: You cannot loop over a stack in the usual way.
{"Image DocumentName": "Stack limitations/idioms", "Image ImageDescription": "Remember: You cannot loop over a stack in the usual way. Stack<Integer> s = new Stack<Integer>(); ... for (int i = 0; i < s.size(); i++) { do something with s.get(i); } Instead, you must pull contents out of the stack to view them. common idiom: Removing each element until the stack is empty. while (!s.isEmpty()) { do something with s.pop();", "Image XResolution": "37", "Image YResolution": "37", "Image ResolutionUnit": "Pixels/Centimeter", "Image Software": "SlidePlayer", "Image YCbCrPositioning": "Centered"}