Discuss / Java / 练习

练习

Topic source

Even

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

public class Main {
public static void main(String[] args) {
Person p1 = new Person();
Person p2 = new Person();
Person p3 = new Person();
System.out.println(Person.getCount());
}
}

class Person {
public static int count = 0;

public Person(){
count += 1;
}

public static int getCount() {
return count;
}
}


  • 1

Reply