Java Object Clone clone(Object a)

Here you can find the source of clone(Object a)

Description

clone

License

Open Source License

Declaration

public static Object clone(Object a) 

Method Source Code

//package com.java2s;
/*/*from   w  w w  . ja v a 2 s  . c o m*/
 * This file is part of Herschel Common Science System (HCSS).
 * Copyright 2001-2010 Herschel Science Ground Segment Consortium
 *
 * HCSS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of
 * the License, or (at your option) any later version.
 *
 * HCSS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General
 * Public License along with HCSS.
 * If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    public static Object clone(Object a) {
        if (a instanceof double[]) {
            return ((double[]) a).clone();
        }
        if (a instanceof float[]) {
            return ((float[]) a).clone();
        }
        if (a instanceof long[]) {
            return ((long[]) a).clone();
        }
        if (a instanceof int[]) {
            return ((int[]) a).clone();
        }
        if (a instanceof short[]) {
            return ((short[]) a).clone();
        }
        if (a instanceof byte[]) {
            return ((byte[]) a).clone();
        }
        if (a instanceof boolean[]) {
            return ((boolean[]) a).clone();
        }
        throw new IllegalArgumentException("The argument is not a number array.");
    }
}

Related

  1. clone(E object)
  2. clone(Object original)
  3. clone(Object value)
  4. clone(String name, String type, int pos)
  5. clone(T array)