The following statement confused me.
"Since Stack is a LIFO structure (Last In First Out i.e. add to the front and remove from the front), it provides methods push(e) and pop() for this purpose, where push adds to the front and pop removes from the front"
I think it should be like "where push adds to the back and pop removes from the back"
For example, I tried the below code..
Code: Select all
Deque<Integer> q = new LinkedList<>();
//Stack<Integer> q = new Stack<Integer>();
q.push(1);
q.push(2);
q.push(3);
System.out.println(q);
I believe its because, deque is pushing in the front and stack is pushing in the back. Am I wrong?
Regards,
Shamran.