I have a Java app that has an array of 2.6 million values which never change. What is the best way to initialize it?
The obvious answer is to put it in code - i.e. something like:
int[] BigArray = new int[] {1, 2, 3, <...>, 2599999, 2600000};
but I am under the impression that this violates some size limit.
I have seen this post that mentions key/value pairs in Properties, but that doesn't seem particularly intuitive - I don't see why I need to have each array entry saved as a key (for the array index) and a value; I should be able to have just the values in order.
The next best way appears to be having the data saved as a file, and then to load the file into the array (or use a List) on startup, with each value on its own line (yes, the line separators take up 2.6MB, but so would 2.6 million commas). Is this a time-intensive way of doing it?