我有一个预定义的ArrayList,其中包含硬编码的值。我该如何将它们添加到堆栈中?这样做的目的是演示堆栈类的pop、push、peek函数。
ArrayList<String> al = new ArrayList<String>();
al.add("A");
al.add("B");
al.add("C");
Stack<String> st = new Stack<String>();
st.push(al); **// This doesn't seem to work.. Will I have to loop it in some way?**
System.out.println(st);
谢谢!