logo

Crowdly

Considera la següent funció getInstance  que retorna la mateixa instància d'un ...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Considera la següent funció getInstance que retorna la mateixa instància d'un objecte cada vegada que es crida:

Per provar que el mètode getInstance retorna sempre la mateixa instància, quin mètode d'assertion hauríem d'utilitzar?

public class Singleton {

    public static Singleton instance;

    private Singleton() {}

    public static Singleton getInstance() {

        if (instance == null) {

            instance = new Singleton();

        }

        return instance;

    }

}
More questions like this

Want instant access to all verified answers on www.vidalibarraquer.net?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!