如何从另一个类构造函数调用变量(长度、宽度、高度)
试图从 A 类调用变量长度、宽度、高度
不能这样做
class A {
int length;
int breadth;
int height;
A(int length,int height,int breadth)
{
this.length=length;
this.height=height;
this.breadth=breadth;
}
}
class B extends A
{
public void display()
{
System.out.println("Length of the rect is "+length);
System.out.println("Height of the rect is "+height);
System.out.println("Breadth of the rect is "+breadth);
}
}
class Inheritence
{
public static void main(String [] args)
{
new A(5,6,7);
new B().display();
}
}
慕的地10843
慕运维8079593
陪伴而非守候
相关分类