CloneNotSupportedException in Java with Examples Last Updated : 24 Sep, 2021 Comments Improve Suggest changes Like Article Like Report CloneNotSupportedException is thrown to show that the clone method in class Object has been called to clone an object, but that the object's class does not implement the Cloneable interface. Hierarchy: Those applications which override the clone method can also throw this type of exception to indicate that an object couldn't or shouldn't be cloned. Syntax: public class CloneNotSupportedException extends Exception Example of CloneNotSupportedException : Java // Java program to demonstrate CloneNotSupportedException class TeamPlayer { private String name; public TeamPlayer(String name) { super(); this.name = name; } @Override public String toString() { return "TeamPlayer[Name= " + name + "]"; } @Override protected Object clone() throws CloneNotSupportedException { return super.clone(); } } public class CloneNotSupportedExceptionDemo { public static void main(String[] args) { // creating instance of class TeamPlayer TeamPlayer t1 = new TeamPlayer("Piyush"); System.out.println(t1); // using try catch block try { // CloneNotSupportedException will be thrown // because TeamPlayer class not implemented // Cloneable interface. TeamPlayer t2 = (TeamPlayer)t1.clone(); System.out.println(t2); } catch (CloneNotSupportedException a) { a.printStackTrace(); } } } Output : Comment More infoAdvertise with us Next Article CloneNotSupportedException in Java with Examples P piyushkr2022 Follow Improve Article Tags : Java Java-Exceptions Practice Tags : Java Similar Reads java.net.BindException in Java with Examples The java.net.BindException is an exception that is thrown when there is an error caused in binding when an application tries to bind a socket to a local address and port. Mostly, this may occur due to 2 reasons, either the port is already in use(due to another application) or the address requested j 2 min read CompositeName clone() method in Java with Examples The clone() method of a javax.naming.CompositeName class is used to return a copy of this composite name object.If you made any changes to the components of this original composite name won't affect the new copy of CompositeName object and vice versa. Syntax: public Object clone() Parameters: This m 2 min read DateFormat clone() method in Java with Examples The clone() Method of DateFormat class is used to create a copy of this DateFormat. It creates another copy of this DateFormat. Syntax: public Object clone() Parameters: The method does not take any parameters. Return Value: The method returns a copy of the DateFormat. Below programs illustrate the 2 min read Date clone() method in Java with Examples The clone() method of Date class in Java returns the duplicate of the passed Date object. This duplicate is just a shallow copy of the given Date object.Syntax: public Object clone() Parameters: The method does not accept any parameters.Return Value: The method returns a clone of the object.Below pr 2 min read CompoundName clone() method in Java with Examples The clone() method of a javax.naming.CompoundName class is used to return a copy of this compound name object. If you made any changes to the components of this original compound name won't affect the new copy of the CompoundName object and vice versa. The clone and this compound name share the same 2 min read Like