Java Singleton Pattern

后端 未结 8 1864
难免孤独
难免孤独 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 05:48

    since getInstance() method is "static" and instance field too, yo can use Singleton.getInstance(); Without creating new exeple of class. Thihs is the poit of singletone

提交回复
热议问题