When an array is constructed, its elements are automatically initialized to their default values. : Array « Java Source And Data Type « SCJP






public class MainClass{

   public static void main(){
      int[] ints = new int[5];
      for(int i=0;i<ints.length;i++){
        System.out.println(ints[i]);
      }
   }

}
0
0
0
0
0








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.