Wednesday 15 January 2014

Add to stack from ArrayList (Java) -


I have an ArrayList that is pre-defined with hardcoded values. How do I add it to the stack? The idea is to show the Stack class pop, push, peak function.

  ArrayList & lt; String & gt; Al = New Arrestist & lt; String & gt; (); Al.add ('a'); Al.add ("b"); Al.add ('C'); Stack & LT; String & gt; St = new stack & lt; String & gt; (); St.push (al); ** // It does not seem to work. Do I have to loop it somehow? ** System.out.println (st);   

Thanks!

Like many collection sections, a method provides:

  St.addAll (al)    

No comments:

Post a Comment