import java.util.Stack;
public class QueueByTwoStacks {
private Stack stack1;
private Stack stack2;
public QueueByTwoStacks() {
stack1 = new Stack();
stack2 = new Stack();
}
public static void main(String[] args) {
QueueByTwoStacks qts = new QueueByTwoStacks();
String[] months = {"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November",
"December"};
for(int i = 0; i < months.length; i++){
qts.offer(months[i]);
}
for(int i = 0; i < months.length; i++ ){
System.out.println(qts.poll());
}
}
public void offer(Object obj){
stack1.push(obj);
}
public Object poll(){
Object obj = null;
if(stack2.empty()){
while(!stack1.empty()){
stack2.push(stack1.pop());
}
obj = stack2.pop();
}else{
obj = stack2.pop();
}
return obj;
}
}