Java anonmyous Array EG


public class Main
{
	public static void main(String[] args) {
		sum(new int[] {2,4,6,8,10});
      //we can't define size of anonymous array
		
	}
	
	static void sum(int[] arr){
	 int sum=0;
	 for(int i:arr){
	     sum+=i;
	 }
	 System.out.println(sum);
	   
	}
}
Mohd Aajam