1  // File: SumArray.java
  2  // An application to demonstrate  one-dimensional arrays
  3  
  4  public class SumArray 
  5  {
  6     public static void main (String[] args)
  7     {  // array declaration
  8        int a[] = new int[10];
  9  
 10        // array declaration, including initialization
 11        int b[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
 12        int total=0;
 13  
 14        /* assign b to a - note the use of array instance variable length */
 15        for (int i = 0; i < b.length; i++)
 16  	a[i] = b[i];
 17  
 18        /* sum the array */
 19        for (int i = 0; i < a.length; i++)
 20  	total += a[i];
 21  
 22        System.out.println( "\n" + "The sum of the array is " + total + "\n");
 23     }
 24  }