您的位置:首页 > 其它

关于继承

2012-03-15 15:34 106 查看
package com.pratice1;

public class Horse {

protected int leg = 0;
String name = null;

public  Horse(int leg){

this.leg=4;
this.name = "马类";
System.out.println("马类的构造函数");
}

public String getName(){
return name;
}

}


package com.pratice1;

public class WhiteHorse extends Horse {

public WhiteHorse(int i){
super(i);
System.out.println("白马类的构造函数");
}

public static void main(String[] args){
WhiteHorse witheHorse = new WhiteHorse(4);
System.out.println(witheHorse.getName());
}
}




内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: