By using object cloning in JAVA, we can create an exact copy of an object. We use the clone() method for this. To implement this, we must need to use the interface, java.lang.Cloneable interface. in the class which we are instantiating. If we do not implement the Cloneable interface in the class, then, upon calling the clone() function, a CloneNotSupportedException is encountered.
The following is the syntax of the function:
protected Object clone() throws CloneNotSupportedException
This can very useful to avoid declaring an object again to create a copy of the method or to create a copy of an instance in a particular state way after its declaration.