top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

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

+2 votes
201 views
How do you prevent for creating another instance of Singleton using clone() method?
posted Apr 30, 2015 by Roshni

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

1 Answer

+1 vote

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 8, 2015 by Karthick.c
...