FileDocCategorySizeDatePackage
Clone1.javaAPI DocExample526Fri Sep 12 10:10:30 BST 2003None

Clone1.java

/** Demonstration of cloning. */
public class Clone1 implements Cloneable {

	/** Clone this object. Call super.clone() to do the work */
	public Object clone() {
		try {
			return super.clone();
		} catch (CloneNotSupportedException ex) {
			System.out.println("Now that's a surprise!!");
			throw new InternalError(ex.toString());
		}
	}

	int x;
	transient int y;	// will be cloned, but not serialized

	/** Display the current object as a string */
	public String toString() {
		return "Clone1[" + x + "," + y + "]";
	}
}