You are on page 1of 1

Anonymous Array

In java it is perfectly legal to create an anonymous array using the following s


yntax.
new <type>[] { <list of values>};
Anonymous array example
new int[]{1,2,3};
The above given example creates a nameless array and initializes it. Here, neith
er name of the array nor the size is specified. It also creates a array which ca
n be assigned to reference or can be passed as a parameter to any method.

You might also like