This code below is a Singleton which means that only one instance of class Singleton can be created. But I was able to create tho instances in class Singleton_Test but the two instances hat the same content regarding instance variable number which is 4 in bot instances. Why is it possible to create two instances from class singleton and why do all singleton instances have the content of the last created Singleton instance? Appreciate your answers. Thomas
You did not create two instances, only one. You have two variables which reference the same singleton instance. You can test that by checking that instance==instance1. The reason they both have the same contents is because they are the same object.