java中显示错误需要标识符是什么意思?

2025-03-21 03:16:42
推荐回答(4个)
回答1:

这几个类是写在一起的还是?
每个类应该都是有构造方法的或者volume,weight这几个方法是要传参数的,但是你的方法是没有传参

回答2:

s1=length*width*high;运算要放到方法体内,还有属性私有化之后不能被继承,除了Cuboid类本身,其他类都没法直接访问到

回答3:

你把属性设置为私有的 不能继承

回答4:

public class Cuboid
{
protected double length;
protected uble width;
protected double high;
protected ouble s1;
protected double s2;
protected ouble s3;

publc void volume()
{
s1=length*width*high;
System.out.println(s1);

}

}
public class CuboidWeight extends Cuboid
{
prodected double density;

public void weight()
{
s2=length*width*high*density;
System.out.println(s2);

}
}
public class CuboidValue extends CuboidWeight
{
double value;

public void none()
{
s3=length*width*high*density*value;
System.out.println(s3);

}
}
class Demo333
{
public static void main(String[] args)
{
length=1;
width =2;
high=3;
density=4;
value=5;
CuboidValue cubo=new CuboidValue();
cubo.volume();
cucuboeight();
cubo. none();
}
}