deep Copy two dimensional array - Java Collection Framework

Java examples for Collection Framework:Array Copy

Description

deep Copy two dimensional array

Demo Code


//package com.java2s;

public class Main {
    public static int[][] deepCopy(int[][] array) {
        int[][] clone = new int[array.length][];

        for (int i = 0; i < clone.length; i++) {
            clone[i] = array[i].clone();
        }//from   w ww  .j a v a  2 s .co m

        return clone;
    }

    public static double[][] deepCopy(double[][] array) {
        double[][] clone = new double[array.length][];

        for (int i = 0; i < clone.length; i++) {
            clone[i] = array[i].clone();
        }

        return clone;
    }
}

Related Tutorials