Java Array Two Dimension to One Dimension array2dCopy(Object[][] src, Object[][] dest)

Here you can find the source of array2dCopy(Object[][] src, Object[][] dest)

Description

deep copy a 2D array

License

Open Source License

Parameter

Parameter Description
src the source array
dest the destination array

Declaration

static public void array2dCopy(Object[][] src, Object[][] dest) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**// w  ww .ja  v  a2s.c o  m
     * deep copy a 2D array
     *
     * @param src       the source array
     * @param dest      the destination array
     */
    static public void array2dCopy(Object[][] src, Object[][] dest) {
        int n = src.length;

        for (int i = 0; i < n; i++) {
            System.arraycopy(src[i], 0, dest[i], 0, n);
        }

    }

    /**
     * deep copy a 2D array
     *
     * @param src       the source array
     * @param dest      the destination array
     */
    static public void array2dCopy(float[][] src, float[][] dest) {
        int n = src.length;

        for (int i = 0; i < n; i++) {
            System.arraycopy(src[i], 0, dest[i], 0, n);
        }

    }

    /**
     * deep copy a 2D array
     *
     * @param src       the source array
     * @param dest      the destination array
     */
    static public void array2dCopy(int[][] src, int[][] dest) {
        int n = src.length;

        for (int i = 0; i < n; i++) {
            System.arraycopy(src[i], 0, dest[i], 0, n);
        }

    }
}

Related

  1. array2dcopy(final String[][] src, final String[][] target)
  2. array2DTo1D(double[][] In)
  3. array2dTo1d(float[][] in)
  4. array2Dto1D(int m, int n, double[][] a)
  5. array2DTo1D(int[][] array2D)