• Home
  • Recent Q&A
  • Java
  • Cloud
  • JavaScript
  • Python
  • SQL
  • PHP
  • HTML
  • C++
  • Data Science
  • DBMS
  • Devops
  • Hadoop
  • Machine Learning
in Design Patterns by
Q:

How can you create Singleton class in java?

1 Answer

0 votes
by

It is two step process. First, make the constructor private so that new operator cannot be used to instantiate the class. Return an object of the object if not null otherwise create the object and return the same via a method.

Related questions

0 votes
asked Oct 16, 2019 in Design Patterns by DavidAnderson
0 votes
asked Oct 16, 2019 in Design Patterns by DavidAnderson
...