RSS
热门关键字:  java  Ajax  JSP  JSF  Struts
当前位置 : 首页>Java>列表

java第二课

来源: 作者: 时间:2007-08-24 点击:
class Fish extends Animal{
void breathe(){
int height;
super.breathe();
super.height=40;
System.out.println(
"Fish bubble");
}

}

class Integration{
public static void main(String[] args){
Animal an
=new Animal();
Fish fh
=new Fish();
an.breathe();
fh.breathe();
System.out.println(
"an.height:"+an.height);
System.out.println(
"fh.height:"+fh.height);
}

}


编译运行:

如果父类中没有不带参数的构造函数,而子类中不带参数的构造函数进行重写了,编译会出错: 

class Animal

上一篇:Java第一课
下一篇:Java第三课
最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册
Google Adsense
相关文章