ContactUs :

Please send your Questions & Answers or Feedback to "mohan@javabook.org"

How do you prevent for creating another instance of Singleton using clone() method?

Since constructor of Singleton class is supposed to be private it prevents creating instance of Singleton from outside but Reflection can access private fields and methods, which opens a threat of another instance. This can be avoided by throwing Exception from constructor as “Singleton already initialized”

Related Posts Plugin for WordPress, Blogger...
Flag Counter