public class ren {
private double height;
private double weight;
public double getHeight() {
return height;
}
public void setHeight(double height) {
this.height = height;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
//打招呼
public void sayhello()
{
System.out.println("hello");
}
}
package lianxiti;
//extends 继承
//object是所有类的 父类。
public class chinaren extends ren
{
public void KongFu()
{
System.out.println("功夫很吊");
}
//重写 覆盖
public void sayhello()
{
System.out.println("你好");
}
}
package lianxiti;
public class textRen {
public static void main(String[] args) {
ren r1 = new ren();
r1.sayhello();
chinaren r2 = new chinaren();
r2.sayhello();
r2.setHeight(180);
r2.setWeight(70);
r2.KongFu();
}
}