N3lly
2017-04-17 09:26
package com.imooc.test2;
public class Tectangle extends Shape {
double length;
double width;
public Tectangle(double length,double width){
this.length=length;
this.width=width;
}
@Override
public double perimeter() {
double perimeter=this.length*2+this.width*2;
return perimeter;
}
@Override
public double area() {
double area=this.length*this.width;
return area;
}
}
//这是我自己建的tectangle类
package com.imooc.test2;
public abstract class Shape {
public abstract double perimeter();
public abstract double area();
}
//这是shape类
eclipse一直在提示我在tectangle里创建的两个方法必须覆盖或实现超类型方法
这是为啥呢
虚心求教 望各位解惑 在此谢过
我想请教一下,你的Initail类里不出错吗,我的 Shape i=new Rectangle();报错了,我是按你的子类和抽象类打的
记得保存代码 在改动代码以后,不然有的错误会一直提示。
我的和你一样 运行或保存就不报错了
····不好意思不好意思,按了保存就不报错了,望各位海涵 不用回答了
Java入门第二季
531293 学习 · 6327 问题
相似问题