Java – Is ArrayList[][] possible?

ArrayList<Integer>[][] matrix = new ArrayList<Integer]>[sizeX][sizeY]();

or

ArrayList<Integer>[][] matrix = new ArrayList<Integer]>()[sizeX][sizeY];

don’t work, I’m starting to think that it’s not even possible to store ArrayLists in a matrix?

Answer

If you still want to use and array:

    ArrayList<Integer>[][] matrix = new ArrayList[1][1];
    matrix[0][0]=new ArrayList<Integer>();
    //matrix[0][0].add(1);

Leave a Reply

Your email address will not be published. Required fields are marked *