Hallo zusammen,
ich habe eine Frage zum Thema Singleton.
Mir leuchtet nicht ganz ein, weshalb die Variable >> instance<< statisch sein soll.
Wo läge der Unterschied, wenn man das >>static<< entfernen würde.
vielen Dank für eure Antworten
Oli
public class Singleton {
private Singleton () {
}
private static final Singleton instance = new Singleton();
public static Singleton getInstance() {
return instance;
}
ich habe eine Frage zum Thema Singleton.
Mir leuchtet nicht ganz ein, weshalb die Variable >> instance<< statisch sein soll.
Wo läge der Unterschied, wenn man das >>static<< entfernen würde.
vielen Dank für eure Antworten
Oli
public class Singleton {
private Singleton () {
}
private static final Singleton instance = new Singleton();
public static Singleton getInstance() {
return instance;
}