Here you can find the source of printMatrix(ArrayList
public static void printMatrix(ArrayList<ArrayList<Integer>> grid)
//package com.java2s; /**// w w w. j a v a 2s.c om * Copyright (C) 2018 Lars Dam * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation version 3.0 * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * See: http://www.gnu.org/licenses/gpl-3.0.html * * Problemen in deze code: * - ... * - ... */ import java.util.ArrayList; public class Main { public static void printMatrix(ArrayList<ArrayList<Integer>> grid) { for (int r = 0; r < grid.size(); r++) { for (int c = 0; c < grid.get(r).size(); c++) System.out.print(grid.get(r).get(c) + "\t"); System.out.println(); } } public static void printMatrix(int grid[][]) { for (int r = 0; r < grid.length; r++) { for (int c = 0; c < grid[0].length; c++) System.out.print(grid[r][c] + "\t"); System.out.println(); } } public static void printMatrix(int grid[]) { for (int r = 0; r < grid.length; r++) { System.out.print(grid[r] + " \n"); } } }