Declaring an Array of Primitives, and declaring an Array of Object References : Array « Java Source And Data Type « SCJP






public class MainClass{
    public static void main(String[] argv){
        int[] key;  // Square brackets before name (recommended)
        int key []; // Square brackets after name (legal but less readable)

        System.out.println();
    }
}   

public class MainClass{
    public static void main(String[] argv){
        Thread[] threads;  // Recommended
        Thread threads1 []; // Legal but less readable
    }
}








1.16.Array
1.16.1.Java Array
1.16.2.Declaration tells the array's name and type
1.16.3.Declares a two-dimensional array
1.16.4.The square brackets can come before or after the array variable name.
1.16.5.All elements of an array must be of the same type allowed by polymorphism.
1.16.6.Declaring an Array of Primitives, and declaring an Array of Object References
1.16.7.We can also declare multidimensional arrays, which are in fact arrays of arrays.
1.16.8.A method that returns an array of doubles
1.16.9.Array size is specified via the new keyword.
1.16.10.It is legal to specify size with a variable rather than a literal
1.16.11.Declaration and construction may be performed in a single line
1.16.12.When an array is constructed, its elements are automatically initialized to their default values.
1.16.13.Arrays must be declared before you use them.