Here you can find the source of copyMatrix(boolean[][] matrix)
public static boolean[][] copyMatrix(boolean[][] matrix)
//package com.java2s; //License from project: Open Source License public class Main { public static boolean[][] copyMatrix(boolean[][] matrix) { int maxY = matrix.length; int maxX = matrix[0].length; boolean[][] copy = new boolean[maxY][maxX]; for (int y = 0; y < maxY; y++) { for (int x = 0; x < maxX; x++) { copy[y][x] = matrix[y][x]; }//from w w w . j ava2 s . c o m } return copy; } }