private satic 注意与应用
- public class Dog
- {
- private static int count; //static member
- public Dog()
- { count++;
- }
- public static void main(String a[])
- { Dog d=new Dog();
- Dog dd=new Dog();
- new Dog();
- Dog.display();
- }
- private static void display()
- {
- System.out.println(count);
- }
- }
- 输出结果为:为3;
- 应用:单例模式:http://calmness.iteye.com/blog/60179
posted on 2012-07-01 17:00 elegantyuanjian 阅读(114) 评论(0) 收藏 举报
浙公网安备 33010602011771号