Java Array Clone clone2dArray(double[][] myArray)

Here you can find the source of clone2dArray(double[][] myArray)

Description

cloned Array

License

Apache License

Parameter

Parameter Description
myArray a parameter

Declaration

public static double[][] clone2dArray(double[][] myArray) 

Method Source Code

//package com.java2s;
/*/*www  .j a va 2 s . co m*/
 * Copyright 2019 James F. Bowring and CIRDLES.org.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {
    /**
     *
     * @param myArray
     * @return
     */
    public static double[][] clone2dArray(double[][] myArray) {
        double[][] arrayCopy = new double[myArray.length][];
        for (int i = 0; i < myArray.length; i++) {
            arrayCopy[i] = myArray[i].clone();
        }

        return arrayCopy;
    }

    /**
     *
     * @param myArray
     * @return
     */
    public static int[][] clone2dArray(int[][] myArray) {
        int[][] arrayCopy = new int[myArray.length][];
        for (int i = 0; i < myArray.length; i++) {
            arrayCopy[i] = myArray[i].clone();
        }

        return arrayCopy;
    }

    /**
     *
     * @param myArray
     * @return
     */
    public static boolean[][] clone2dArray(boolean[][] myArray) {
        boolean[][] arrayCopy = new boolean[myArray.length][];
        for (int i = 0; i < myArray.length; i++) {
            arrayCopy[i] = myArray[i].clone();
        }

        return arrayCopy;
    }

    public static String[][] clone2dArray(String[][] myArray) {
        String[][] arrayCopy = new String[myArray.length][];
        for (int i = 0; i < myArray.length; i++) {
            arrayCopy[i] = myArray[i].clone();
        }

        return arrayCopy;
    }
}

Related

  1. clone(T[] array)
  2. clone(T[] array)
  3. clone(T[] array)
  4. clone2DArray(double[][] a)
  5. clone2DArray(Double[][] array)
  6. clone2DArray(final boolean[][] array)
  7. clone_multidim_array(float[][] arr)
  8. cloneAndMultiplyArray(float[] array, float factor)
  9. cloneArray(boolean[][] src)