开发者社区 问答 正文

饿汉式单例

饿汉式单例

展开
收起
游客pklijor6gytpx 2019-12-02 16:15:15 772 分享 版权
1 条回答
写回答
取消 提交回答
  • public class Singleton {
        private Singleton(){}
        private static Singleton instance = new Singleton();
        public static Singleton getInstance(){
            return instance;
        }
    }
    
    2019-12-02 16:15:40
    赞同 展开评论
问答地址: