Problem of creating a Java 2d array

0

I have the following code which I need to create a bidimentional array in a dynamic way. The problem arises when you want to create the two-dimensional array fixTemp while assigning the array variable. The compiler tells me it's not easy.

    int arregloTemp[][] = new int[arregloDeArreglosBinarios.size()][];

    for(int i = 0; i < arregloDeArreglosBinarios.size(); i++) {
        int []arreglo = arregloDeArreglosBinarios.get(i);

        for(int j = 0; j <= arreglo.length; j++) {

            arregloTemp[i] = new int []{arreglo};
        }
    }
    
asked by Eduardo Tolentino 17.11.2018 в 12:02
source

1 answer

0

You have it this way

for(int j = 0; j <= arreglo.length; j++) {

            arregloTemp[i] = new int []{arreglo};
        }

It is not possible in what I see because you are trying to put another arrangement in a position of an arrangement and that is not possible to do, besides I think you must specify well the position of the two-dimensional array with rows and columns where you assign the variable .

    
answered by 17.11.2018 в 16:44