In Java, I want to print the contents of a Stack. The toString() method prints them encased in square brackets delimited by commas: [foo, bar, ba
toString()
[foo, bar, ba
There is a workaround.
You could convert it to an array and then print that out with Arrays.toString(Object[]):
Arrays.toString(Object[])
System.out.println(Arrays.toString(myStack.toArray()));