An array can be initialized by assigning a value to each element : Array Elements « Java Source And Data Type « SCJP






public class MainClass {

  public static void main(String[] argv) {
    long[] squares;
    squares = new long[6000];
    for (int i = 0; i < 6000; i++) {
      squares[i] = i * i;
    }
  }
}








1.17.Array Elements
1.17.1.Array Element Initialization Values
1.17.2.Combine declaration, construction, and initialization into a single step
1.17.3.The array size is inferred from the number of elements within the curly braces.
1.17.4.An array can be initialized by assigning a value to each element
1.17.5.Create a 20 by 30 array of String objects