In Java, when is the {a,b,c,…} array shorthand inappropriate, and why?

You can use braces notation only at the point of declaration, where compiler can infer the type of array from the declaration type.

To use it anywhere else you need to use Array Creation Expression:

return new double[] {0,1,2};

Leave a Comment