Is it possible to create an array of 2D int arrays like:
int n = 100;
int[][] [] a = new int[][] [n];
Array has a fixed length n and matrices (2D arrays) have different non-zero sizes (at least 1 x 1).
For performance I would like to store that in the stack, not like:
ArrayList<int[][]> a = new ArrayList<int[][]>(n);
which will be stored on the heap as far as I know.
To create a 3D array
int n = 100;
int[][][] a = new int[n][][];
This creates 100 array of array of any dimension.
This is almost as (in)efficient as
List<int[][]> a = new ArrayList<int[][]>(n);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With