switch (dimensions) {
case 1: double[] array = new double[10]; break;
case 2: double[][] array = new double[10][]; break;
case 3: double[][][] array = new double[10][][]; break;
case 4: double[][][][] array = new double[10][][][]; break;
case 5: double[][][][][] array = new double[10][][][][]; break;
case 6: double[][][][][][] array = new double[10][][][][][]; break;
default: System.out.println("Sorry, too many dimensions"); break;
}
有没有更好的方法来完成上述操作?我希望它能够创建任意维度的数组,而且...