package bi.shi.demo;
/**
* @program: bi_shi_test
* @description: 编写一个singleton出来
* @author: xin yi
* @create: 2021-09-11 11:16
*/
public class Singleton {
public static void main(String[] args) {
MainWindow mainWindow = new MainWindow();
mainWindow.showMessage();
}
}
class MainWindow{
private static Singleton instance = new Singleton();
MainWindow(){}
private static Singleton getInstance(){
return instance;
}
public void showMessage(){
System.out.println("hello");
}
}
编写一个singleton出来
最新推荐文章于 2023-06-15 17:22:31 发布