Discuss / Java / 练习

练习

Topic source

ypx0410

#1 Created at ... [Delete] [Delete and Lock User]
public class Hello {
    public static void main(String[] args) {
    	Person p1 = new Person();
    	System.out.println(Person.getCount());
    	Person p2 = new Person();
    	System.out.println(Person.getCount());
    	Person p3 = new Person();
    	System.out.println(Person.getCount());
     }
}

class Person{
	public static int count;
	public Person() {
		count++;
	}
	
	public static int getCount() 
	{
		return count;
	}
}


  • 1

Reply