Java Singleton Pattern

  • + 1 comment

    Because when you call getSingleInstance(), it will return a new object every time. In other words, you can make an unlimited number of objects with that method.


    By making a private object (in this case, the object "instance"), your function doesn't return a new object each time - it returns the only Singleton object available, which is "instance" and you can't make any more objects from the Singleton class (which is exactly the idea behind the Singleton pattern).


    I hope this cleared up any confusion.