clone int array - Java java.lang

Java examples for java.lang:int Array

Description

clone int array

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        int[] array = new int[] { 34, 35, 36, 37, 37, 37, 67, 68, 69 };
        System.out.println(java.util.Arrays.toString(clone(array)));
    }//from   w  w w .j  a va  2  s  . c  o  m

    public static int[] clone(int[] array) {
        int[] copy = new int[array.length];
        for (int i = 0; i < array.length; i++) {
            copy[i] = array[i];
        }
        return copy;
    }
}

Related Tutorials