vendredi 24 novembre 2017

How does singleton class Work and Idea behind it? [on hold]

Here my code:

  private static JavaClass INSTANCE = null;

    public static JavaClass getInstance()
    {
        if ( INSTANCE == null )
        {
            INSTANCE = new JavaClass();
        }
        return INSTANCE;
    }

private JavaClass() {
        }

What is the use of this pattern and how does it work?

Aucun commentaire:

Enregistrer un commentaire