当前位置:编程学习 > JAVA >>

请问下列两个错误怎么解决,本人刚学Java

public class Test2
{

public static void main(String[] args)
{
//Shape shape = new Rectangle(1,2);

Rectangle shape = new Rectangle(1,2);

System.out.println("The length of rectangle is "+shape.length);

System.out.println("The width of rectangle is "+shape.width);

int area = shape.getArea();

System.out.println("The area of rectangle is "+area);

}
}
abstract class shape
{

public abstract int getArea();

}
class Rectangle extends shape
{
int length;

int width;

Rectangle(int length,int width)
{
this.length = length;

this.width = width;

}
int getArea();
{
return (this.length * this.width);
}
}

java --------------------编程问答-------------------- Rectangle 类中的int getArea();
{
return (this.length * this.width);
}
改成public  int getArea()
{
return (this.length * this.width);
}
子类的访问权限不能比父类的访问权限低 --------------------编程问答-------------------- public --------------------编程问答--------------------
引用 2 楼 zyc13701469860 的回复:
public
+1
补充:Java ,  Java SE
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,