I'm just playing around with my code, and was wondering if initializing a multidimensional array with the enhanced for loop is possible.
How do I fix this?
double[][] array2 = new double[2][5];
int b=1;
counter=0;
for(double[] x:array2)
{
for(double a:x)
{
array2[][counter]=b; //<- errors here
counter++;
b+=2;
}
}
//output what it contains
for(double[] x:array2)
{
for(double a:x)
{
System.out.println(a);
}
}
How would you guys do it with 3 dimensions?
double[][][] array3 = new double[4][5][6];
I know I could use Collections for this stuff but I was just trying things out.