import java.util.Scanner;
public class testFixedCapacityStack {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
FixedCapacityStack<String> s;
s = new FixedCapacityStack<String>(100);
while(sc.hasNext()) {
String item = sc.next();
if(!item.equals("-")) {
s.push(item);
} else if (!s.isEmpty()) {
System.out.print(s.pop() + " ");
}
}
System.out.println(s.size());
}
}
I have no idea why the last line is not getting executed. Someone please point out where I did wrong. Thank you.