Java Array Copy copyArray(int[][] src)

Here you can find the source of copyArray(int[][] src)

Description

copy Array

License

Open Source License

Declaration

public static int[][] copyArray(int[][] src) 

Method Source Code

//package com.java2s;
/*/*from  w  w  w .j av  a2 s.c  om*/
 * Copyright ? 2013, Olivier MARTIN, aka ekki77
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
 *
 * The Software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders X be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the Software.
 *
 * Except as contained in this notice, the name of the copyright holders shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the copyright holders.
 */

public class Main {
    public static int[][] copyArray(int[][] src) {
        int[][] ret = new int[src.length][src[0].length];
        for (int i = 0; i < ret.length; i++) {
            System.arraycopy(src[i], 0, ret[i], 0, src[0].length);
        }
        return ret;
    }

    public static boolean[][] copyArray(boolean[][] src) {
        boolean[][] ret = new boolean[src.length][src[0].length];
        for (int i = 0; i < ret.length; i++) {
            System.arraycopy(src[i], 0, ret[i], 0, src[0].length);
        }
        return ret;
    }
}

Related

  1. copyArray(double[][] d)
  2. copyArray(int[] ar)
  3. copyArray(int[] inArr, int[] outArr)
  4. copyArray(int[][] arr)
  5. copyArray(int[][] links, int rowNum, int columnNum)
  6. copyArray(int[][][] data)
  7. copyArray(long[] array)
  8. copyArray(Object source, Object dest, int count)
  9. copyArray(Object[] array)