The documentation for the Cloneable says -
Note that this interface does not contain the clone method. Therefore, it is not possible to clone an object merely by virtue of the fact that it implements this interface. Even if the clone method is invoked reflectively, there is no guarantee that it will succeed.
But the following code is working correctly. It is not giving any error when I call ex1.clone.
package com.sriPushpa.thread;
public class exceptionHandling implements Cloneable {
int a = 10;
public static void main(String args[]) {
exceptionHandling ex1 = new exceptionHandling();
exceptionHandling ex2 = null;
try {
ex2 = (exceptionHandling) ex1.clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
System.out.println("SUCCESS");
}
}