

Hi,
The Cloneable interface defines no members. It is used to indicate that a class allows a bitwise copy of an object (that is, a clone) to be made. If you try to call clone( ) on a class that does not implement Cloneable, a CloneNotSupportedException is thrown. When a clone is made, the constructor for the object being cloned is not called. A clone is simply an exact copy of the original.
Thanks.

Hi,
The Cloneable interface defines no members. It is used to indicate that a class allows a bitwise copy of an object (that is, a clone) to be made. If you try to call clone( ) on a class that does not implement Cloneable, a CloneNotSupportedException is thrown. When a clone is made, the constructor for the object being cloned is not called. A clone is simply an exact copy of the original.
Thanks.

Hi,
The Cloneable interface defines no members. It is used to indicate that a class allows a bitwise copy of an object (that is, a clone) to be made. If you try to call clone( ) on a class that does not implement Cloneable, a CloneNotSupportedException is thrown. When a clone is made, the constructor for the object being cloned is not called. A clone is simply an exact copy of the original.
Thanks.

The Example of cloneable interface-
class TestCloneDemo implements Cloneable {
int a;
double b;
// This method calls Object's clone().
TestCloneDemo cloneTest() {
try {
// call clone in Object.
return (TestCloneDemo) super.clone();
} catch (CloneNotSupportedException e) {
System.out.println("Cloning not allowed.");
return this;
}
}
}
public class CloneDemo {
public static void main(String args[]) {
TestCloneDemo x1 = new TestCloneDemo();
TestCloneDemo x2;
x1.a = 15;
x1.b = 35.05;
x2 = x1.cloneTest(); // clone x1
System.out.println("x1: " + x1.a + " " + x1.b);
System.out.println("x2: " + x2.a + " " + x2.b);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.