class Parent {
private String name=null;
private int health=0;
private String sex=null;
public Parent() {
health = 10;
sex = "雄";
System.out.println("执行构造方法。");
}
public void print() {
System.out.println("企鹅的名字是" + name + ",健康值是" + health + ",性别是" + sex+ "。");
}
public static void main(String[] args) {
Penguin pgn = new Penguin();
pgn.print();
}
} |
|