Array length

Anonymous Arrays

Some times we can declare an array with out name also such type of arrays are called anonymous arrays.
The main objective of anonymous arrays is just for temporary usage. We can create an anonymous arrays as follows.
Example:

class Test{
public static void main(String arg[]){
  System.out.println(sum(new int[]{10,20,30,40}));
}
public static int sum(int[] a){
 int total = 0;
 for(int i = 0; i< a.length;i++){
   total = total + a[i];
 }
 return total;
 }
}