userimage

Need some Examples of singleton patterns from java development kit?

Give me some examples on this ,as i am new to this?


userimage

Some Basic overview on Singleton

  • Singleton pattern in Java is used to create a Singleton class which is accessed by single instance though out Java program life cycle.
  • Singleton is one of the old but very useful design pattern and used in several core Java libraries including Java Development Kit (JDK);
  • java.lang.Runtime is an example of Singleton pattern in Java. This class represent single instance of Java environment running as JVM and provides several utility method to query important details about runtime like number of available processor, Java heap memory etc.
  • Singletons are also very popular in Java interview and one of the frequently asked question.

In Summary Singleton is very useful design pattern and Java programmer must be familiar with What is Singleton in Java, How to create Singleton classes, issues faced to maintain Singleton status etc. By using Enum as Singleton we get some benefits in terms of these issues.

Answer is