vendredi 22 juillet 2016

java double double check singleton instance error

I am trying to implement double check but getting this error.

static UserPayments singletonInstance;

public static volatile UserPayments getSingletonInstance(){
if (null == singletonInstance) {
    synchronized (UserPayments.class){
        if (null == singletonInstance){
            singletonInstance = new UserPayments();
        }
    }
}
return singletonInstance;

}

Illegal modifier for the method getSingletonInstance; only public, protected, private, abstract, static, final, synchronized, native & strictfp are permitted

Aucun commentaire:

Enregistrer un commentaire