top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How do you prevent for creating another instance of Singleton using reflection?

+3 votes
311 views
How do you prevent for creating another instance of Singleton using reflection?
posted May 12, 2015 by Karthick.c

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Preferred way is not to implement Cloneable interface as why should one wants to create clone() of Singleton and if you do just throw Exception from clone() method as “Can not create clone of Singleton class”.

answer May 13, 2015 by Shyam
...