chap4-8.txt
来自「JAVA 学习资源」· 文本 代码 · 共 29 行
TXT
29 行
// 程序4-8
class point{
int x, y;
point(int x, int y){ // point类构造函数
this.x=x;
this.y=y;
System.out.println("父类构造函数被调用!");
}
}
class circle extends point{
int radius;
circle(int r, int x, int y){ // 子类构造函数
super(x, y); // super必须写在构造函数的第一行
radius=r;
System.out.println("子类构造函数被调用!");
}
}
public class testInherence {
public static void main(String args[ ]) {
circle c1;
c1=new circle(1,1,1);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?