أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.
The class will need to implement the clone() mehod as below:
public class Singleton {
private static final Singleton singleton = new Singleton();
private Singleton() { }
public static Singleton getInstance(){
return singleton;
}
@Override
protected Object clone() throws CloneNotSupportedException {
throw new CloneNotSupportedException("Cloning of this class is not allowed");
}
}
If your class which is based on the Singleton pattern does not implement the Cloneable interface then the clone() method cannot be called on that object.
هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟