So I'm declaring and initializing an int array:
static final int UN = 0;
int[] arr = new int[size];
for (int i = 0; i < size; i++) {
arr[i] = UN;
}
Say I do this instead...
int[] arr = new int[5];
System.out.println(arr[0]);
... 0
will print to standard out. Also, if I do this:
static final int UN = 0;
int[] arr = new int[5];
System.out.println(arr[0]==UN);
... true
will print to standard out. So how is Java initializing my array by default? Is it safe to assume that the default initialization is setting the array indices to 0
which would mean I don't have to loop through the array and initialize it?
Thanks.