In object-oriented programming , a singleton class is a class that can have only one object (an instance of the class) at a time.Below is the example of singleton class in Java.
For more update about android click below link
For more update about android click below link
Click below for more update about androidpublic class ClassicSingleton {private static ClassicSingleton instance = null;
protected ClassicSingleton() {
// Exists only to defeat instantiation.
}
public static ClassicSingleton getInstance() {
if(instance == null) {
instance = new ClassicSingleton();
}
return instance;
}
}
No comments:
Post a Comment