How to avoid initialization of a large array
arrays, java
Solution
Short answer: No. Arrays always get zeroed out when they are created.
If your profiling has shown this to be a major bottleneck, you could consider keeping a pool of array instances, with the length of each set to bigger than `n` will ever be. The problem would be that you then probably need a wrapper object to contain the data array and the actual length that is used, since you can no longer use `data.length`.
Problem
I allocate a large array of doubles as ``` double[] x = new double[ n ]; ``` where n is large, and I want to avoid initialization to save time. Is it possible?