Here you can find the source of loadNDimDoubleMatrixRec(Scanner reader, int[] dim, Object nmatrix)
public static void loadNDimDoubleMatrixRec(Scanner reader, int[] dim, Object nmatrix)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; import java.util.Scanner; public class Main { public static void loadNDimDoubleMatrixRec(Scanner reader, int[] dim, Object nmatrix) { if (dim.length == 1) { for (int i = 0; i < dim[0]; i++) { ((double[]) nmatrix)[i] = reader.nextDouble(); }/* www . j a v a2 s .c om*/ } else { int[] newDim = Arrays.copyOfRange(dim, 1, dim.length); for (int i = 0; i < dim[0]; i++) { loadNDimDoubleMatrixRec(reader, newDim, ((Object[]) nmatrix)[i]); } } } }