I want to create a 10 dimensional array that's filled with zeros.
If I simply use int[] array = new int[10]; do I have a guarantee that all int's in the array are zeros?
3 Answers
Yes, but it's only one-dimensional, not ten.
3 Comments
Michael Borgwardt
And a ten-dimensional array of size 10 in all dimensions would require 37GB of memory, if I calculated correctly.
Peter Lawrey
I calculate 10^9 * (8 (reference to) + 16 (array header) + 10*4) which is ~ 60 GB. ;)
Andrew White
Orrrrr... it's a ten-dimensional array that can hold 32 enumerable states :)
Doing a new int[10] will be plenty. Refer to the authority for the default values.
2 Comments
Stephen C
The REAL authority is JLS 15.10.1 (paragraph 5).
Andrew White
I looked but couldn't find a link very quickly and figured Oracle was enough of an authority; thanks for the spec though
int[][][][][][][][][][] array;is not the same thing as a 1 dimensional array with 10 elements :new int[10].