Here you can find the source of clone(Object original)
Parameter | Description |
---|---|
original | The Object to be cloned |
Parameter | Description |
---|---|
CloneNotSupportedException | if the original object is not cloneable |
public static Object clone(Object original) throws CloneNotSupportedException
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License") public class Main { /**// w ww.j a v a 2 s .c o m * Returns a clone of the given original Object * @param original The Object to be cloned * @return A clone of the original object * @throws CloneNotSupportedException if the original object is not cloneable */ public static Object clone(Object original) throws CloneNotSupportedException { if (!(original instanceof Cloneable)) throw new CloneNotSupportedException(); try { return original.getClass().getMethod("clone").invoke(original); } catch (Exception e) { throw new CloneNotSupportedException(); } } }