Anonymous Arrays in java

Sometimes we can create an array without name also , such type of nameless array is known as Anonymous Array .

Array without having any name is called Anonymous Array.

The main object of anonymous arrays is , it is created only for instant use.

Syntax of creating Anonymous Array

new DataType[ ]{values} ;

//example of anonymous array
class Example {

    public static void print(int a[]) {
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i] + "\t");

    public static void main(String[] args) {
        //we will pass anonymous array in print() method
        Example.print(new int[]{1, 3, 2});
1	3	2