When I try to pass an array initializer as a method argument I get an error with the message 'Array initializer is not allowed here'.
methodTakingArrayArgument({0,0,0})
However, the construct works when the type is mentioned explicitly.
methodTakingArrayArgument(new int[]{0,0,0})
Is there a reason that this construct is not supported? There seems to be no documentation on the oracle website mentioning the same.
Edit: I understand that there are a fixed number of ways to create an array in Java. The array initializer construct felt natural to be supported as a first class citizen in Java, like in languages like typescript.
As one of the answers has pointed out, the array initializer is not a valid expression, which is why it cannot be passed on to a method.