Posted on 2018-10-21 09:38  咳咳你  阅读(124)  评论(0)    收藏  举报
package lol;

public class j {
    private static int n;
    public j()
    {
        n++;
    }
    public static int getNum()
    {
        return n;
    }
    public static void main(String[] args) {
       
        j t1=new j();
        j t2=new j();
        j t3=new j();
        System.out.println("一共有对象个数:"+j.getNum());
    }

}