How to write a Singleton in proper manner?

后端 未结 13 1098
走了就别回头了
走了就别回头了 2020-12-23 12:03

Today in my interview one interviewer asked me to write a Singleton class. And i gave my answer as

public class Singleton {

    private static Singleton re         


        
相关标签:
13条回答
  • 2020-12-23 13:00

    Some times We might have to Create one instance of a subclass only Like Java Toolkit class. Example 1: Creating one instance of a subclass only will be elaborating out it. Please Refer: Singleton Design Patter in Java

    0 讨论(0)
提交回复
热议问题