static关键字
public class Dog2 {
public static String name;
public static int health;
public static int love;
public static String strain;
public Dog2(){
System.out.println("调用了无参数构造方法");
}
public Dog2(String name, int health, int love, String strain) {
this.name = name;
this.health = health;
this.love = love;
this.strain = strain;
}
public void print(){
System.out.println(name+"\t"+health+"\t"+love+"\t"+strain);
}
public int print(int num){
System.out.println(num);
this.print();
return num+1;
}
}
public class Test {
public static void main(String[] args) {
Dog2.name="珂珂";
Dog2.health=99;
Dog2.love=99;
Dog2.strain="100";
}
}
