I defined List stack = new ArrayList();
List stack = new ArrayList();
When I\'m trying to convert it to an array in the following way:
Do this instead:
Integer[] array = stack.toArray(new Integer[stack.size()]);
We need to pass the "seed" array as an argument to the toArray method.
toArray