'What is a singleton, in plain English?

I've been Googling for about an hour now and I still don't have a clear idea of what a singleton is. Can anyone make it a bit clearer to me and perhaps post a code example?

All I know is that you can only have one instance of a given class. But can't you just then use a static class for that?

Thanks in advance!



Solution 1:[1]

singleton is a class with a private constructor and you could only get one instance of it. for further explanation why this coding style is done I suggest you read the chapter regarding singletons in this book

http://www.wowebook.com/book/head-first-design-patterns/

Chapter 5 is all about singleton

Solution 2:[2]

The singleton pattern is a design pattern that restricts the instantiation of a class to one object.

Note the distinction between a simple static instance of a class and a singleton: although a singleton can be implemented as a static instance, it can also be lazily constructed, requiring no memory or resources until needed. Another notable difference is that static member classes cannot implement an interface, unless that interface is simply a marker. So if the class has to realize a contract expressed by an interface, it really has to be a singleton.

All from Wikipedia

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Oneb
Solution 2