Printing Java Collections Nicely (toString Doesn’t Return Pretty Output)

You could convert it to an array and then print that out with Arrays.toString(Object[]):

System.out.println(Arrays.toString(stack.toArray()));

Leave a Comment