1. Make your class final (so that no cloneable sub-class can be created)
2. In case of non-final class, Override the clone method of Object
class in your class and inside the body of the method just throw a
CloneNotSupportedException.
ex:
public final class MyClass
{
protected Object clone() throws CloneNotSupportedException
{
throw new CloneNotSupportedException();
}
}
Top 7 Books and Udemy Online Courses to Crack the PMP Certification Exam in
2025 - Best of Lot
-
If you are in the Project management and People management area, then you
might have heard about *PMP certifications*, one of the most reputed and
sought-...
1 hour ago
No comments:
Post a Comment
I'm certainly not an expert, but I'll try my hardest to explain what I do know and research what I don't know.