Discuss / Java / 思考题

思考题

Topic source

风之子

#1 Created at ... [Delete] [Delete and Lock User]

public class Static {

  public static void main(String[] args) {

    Person a = new Person();

    Person.getCount();

    Person b = new Person();

    Person.getCount();

    Person c = new Person();

    Person.getCount();

  }

}

class Person {

  public static int count;

  public static void getCount() {

    System.out.printf("创建了%d个实例了\n", count);

  }

  public Person() {

    count++;

  }

}


  • 1

Reply