mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-24 13:24:05 -06:00
468 B
468 B
#cs240 When you want to have only one instance of an object in all of your code, you define its constructor as private, and create a public static getInstance method. The single instance is put into a private static variable.
public class DataCache {
private static DataCache instance;
public static DataCache getInstance() {
if(instance == null) {
instance = new DataCache();
}
return instance;
}
private DataCache(){
}
}