dimanche 26 mars 2017

Singleton Design Pattern-Java

Does the class below implement the singleton pattern? I'm really confused.

class Customer {

    static private Map costumers = new HashMap();

    private Customer() {
    }

    public static Customer getInstance(String name) {
        Customer instance = (Customer) costumers.get(name);
        if (instance == null) {
            instance = new Customer();
            costumers.put(name, instance);
        }
        return instance;

    }
}

Thanks.

Aucun commentaire:

Enregistrer un commentaire