Does any one know differences of this two approach?
public class SingleTone {
private static final instance = new SingleTone();
private SingleTone() {
}
public [static] SingleTone getinstance() {
return instance;
}
}
and
public class SingleTone {
private static instance = new SingleTone();
private SingleTone() {
}
public [static] SingleTone getinstance() {
return instance;
}
}
I know final static variables are thread-safe however i can't find any problem with non-final one. (NOTE: I'm seeking the differences of final static variables with non-final static variables so please don't suggest how to implement the Singleton design pattern. I know there is an Enum approach.)
Edited: I missed static keyword on method now its fixed!