What do you mean with a named array?
a_1 in your case will be x[0].
Closed you can get is this:
int a1[], a2[];
int aa[][] = { (a1 = new int[] { 1 }), a2 = new int[] { 2, 3 } };
But the array of arrays hardly add value here.
If you just want to init a multidimensional array, do it like this:
int ba[][] = { { 1 }, { 2, 3 }, { 2, 3, 4 }, { 2, 3, 4 } };
You can also fill it with the same value using Arrays
, sadly it only support the first level.
int c1[] = new int[5];
Arrays.fill(c1, 5);
int ca[][] = { Arrays.copyOf(c1, 5),
Arrays.copyOf(c1, 5),
Arrays.copyOf(c1, 5) };
Or:
int da[][] = new int[5][5];
for (int i = 0; i < da.length; i++) {
Arrays.fill(da[i], 5);
}
Or possibly:
int ea[][] = new int[5][5];
for (int i = 0; i < ea.length; i++) {
for (int j = 0; j < ea[i].length; j++) {
ea[i][j] = 5;
}
}
With foreach:
int fa[][] = new int[5][5];
for (int[] is : fa) {
Arrays.fill(is, 5);
}
and:
int ga[][] = new int[5][5];
for (int[] is : ga) {
for (int i : is) {
i = 5;
}
}