What is singleton class? Where is it used?

What is singleton class? Where is it used?

- It is a design pattern which restricts the instantiation of a class to one object.

- The main purpose of singleton class is to control object creation, limiting the number of objects to one only.

- A class is defined as a singleton class, if and only if it can create only one object.

- This class is useful when only one object is to be used in the application.

The following are the uses of the singleton class:

1. The access of the object is controlled.
2. When "just-in-time" instantiation is needed globally.
3. It is useful when one object is needed to coordinate actions across the system.
What is a native method?
What is a native method? - A native method is a method which is implemented in a non-java language that is targeted for a single machine type...
Difference between a public and a non-public class
Difference between a public and a non-public class - A class with access specifier ‘public’ can be accessed across the packages...
What is the purpose of the Runtime class?
Purpose of the Runtime class - The java runtime system can be accessed by the Runtime class...
Post your comment