A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

单例模式代码:
        懒汉式:
        class Single{
        private static Single s = null;
        private Single(){}
        public static Single getIntance(){
                if (s == null){
                        s = new Single();
                }
                return s;
        }
}
        饿汉式:
        class Single{
        private static Single s = new Single();
        private Single(){}
        public static Single getIntance(){
                return s;
        }
}

3 个回复

正序浏览
不错不错   32个赞~~~
回复 使用道具 举报
yelebron 发表于 2015-4-24 21:27
不错不错加油加油!!!

谢谢谢谢  一起加油
回复 使用道具 举报
不错不错加油加油!!!
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马