I have declared a stack of integer array -
Stack<int[]> stack = new Stack<int[]>();
When I am pushing an object to stack using following code, I am getting an error -
stack.push({0,0});
But it works when I use the following code -
stack.push(new int[]{0,0});
So I am bit confused why the first way did not work. Does {0,0}
not declare a new array object which can be pushed on the stack?