I want to output the contents of each stack after the code below has executed. so far its outputting as
Stack@568db2f2
Stack@378bf509
Stack@378bf509
but I want the contents of each stack.
Code:
public static void main(String[] args) {
Stack<Integer> a = new Stack<>();
Stack<Integer> b = new Stack<>();
Stack<Integer> c = new Stack<>();
a.push(28);
b.push(a.pop());
b.peek();
c.push(21);
a.push(14);
a.peek();
b.push(c.pop());
c.push(7);
b.push(a.pop());
b.push(c.pop());
System.out.println(a);
System.out.println(b);
System.out.println(b);
}