I am new to Java learning the collection topics. Can anyone let me know why the output varies when push method is used in ArrayDeque and Stack ?
ArrayDeque sample program :
public class Simple4 {
public static void main(String[] args) {
// TODO Auto-generated method stub
ArrayDeque q = new ArrayDeque();
q.push("e");
q.push("f");
System.out.println(q);
}
}
Output : [f, e]
Stack Sample program:
public class Simple5 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Stack s = new Stack();
s.push("apple");
s.push("banana");
System.out.println(s);
}
}
Output : [apple, banana]