Java Singleton Pattern

后端 未结 8 1863
难免孤独
难免孤独 2020-12-03 05:22

Edit: Answered - error was method wasn\'t static

I\'m used the Singleton Design Pattern

 public class Singleton {
   private static final Singleton I         


        
8条回答
  •  攒了一身酷
    2020-12-03 06:01

    There is nothing wrong in using

    Singleton singleton = Singleton.getInstance();
    // error - non-static method cannot be referenced from a static context
    

    This is the way to get the singleton object form the class. There must me something else. Please post some more details

提交回复
热议问题