static关键字

 1 public class Cat
 2 {
 3     private static int sid=0;
 4     private String name;
 5     int id;
 6     Cat(String name)
 7     {
 8        this.name=name;
 9        id=sid++;
10     }            
11     public void info()
12     {
13        System.out.println(id);
14     }
15     public static void main(String arg[])
16     {
17        Cat.sid=100;
18        Cat mimi=new Cat("mimi");
19        Cat mimi1=new Cat("mimi");
20        Cat.info();       
21     }
22 }

 

posted @ 2013-04-01 15:54  glt66  阅读(113)  评论(0编辑  收藏  举报