H
horvath.alexandru
Hello.
I have the following singleton:
public class Singleton {
private static final Singleton singleton = new Singleton();
private ArrayList<String> list = new ArrayList<String>();
private Singleton() {
}
public static Singleton getInstance() {
return singleton;
}
// ..... and some public methods to access "list";
}
..... and i have the following class:
public class Usage {
private final Singleton singletonInstance =
Singleton.getInstance();
}
My question is: it is ok that in Usage class the singletonInstance is
declared final? can i still add/delete from the list declared in the
Singleton? Why?
Thank you in advance
I have the following singleton:
public class Singleton {
private static final Singleton singleton = new Singleton();
private ArrayList<String> list = new ArrayList<String>();
private Singleton() {
}
public static Singleton getInstance() {
return singleton;
}
// ..... and some public methods to access "list";
}
..... and i have the following class:
public class Usage {
private final Singleton singletonInstance =
Singleton.getInstance();
}
My question is: it is ok that in Usage class the singletonInstance is
declared final? can i still add/delete from the list declared in the
Singleton? Why?
Thank you in advance