我有一个用硬编码值预定义的 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);
谢谢!