What is the output of the following Java program?
import java.util.ArrayDeque;
import java.util.Deque;
public class Main {
public static void main(String[] args) {
Deque<Integer> st = new ArrayDeque<>();
st.push(1); st.push(2); st.push(3);
st.pop();
st.push(4); st.push(5);
st.pop();
System.out.println(st.peek() + " " + st);
}
}
push adds at the head and pop removes from the head, so toString lists the stack from top to bottom.