How to add int values and then iterate through stack getting LIFO order? Adding 7 and 1 returns 7 and 1.
public void calculate_10to99() {
Stack romanNumeralsStack = new Stack();
romanNumeralsStack.add(7);
romanNumeralsStack.add(1);
Iterator value = romanNumeralsStack.iterator();
while (value.hasNext()){
System.out.println(value.next());
}
Do it like this:
The iterator() method comes from its superclass Vector and just returns all of the elements in order, so iterator.next() does not give you LIFO