CodesJava

Easy learning with example program codes

what is an anonymous array in java?


An array without any name is anonymous array in java.

Example

package com.codesjava;
 
public class Test {
  public static void main(String args[]){
	//Creating anonymous arrays		  
        System.out.println(new int[]{11, 22, 13, 14, 51}.length);  
        System.out.println(new int[]{21, 64, 65}[2]); 
  }
}

Output

5
65


Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap