java中显示错误需要标识符是什么意思?
classCuboid{privatedoublelength;privatedoublewidth;privatedoublehigh;privatedoubles1;...
class Cuboid{ private double length; private double width; private double high; private double s1; private double s2; private double s3;
s1=length*width*high; void volume() { System.out.println(s1); } }class CuboidWeight extends Cuboid{ double density; s2=length*width*high*density; void weight() { System.out.println(s2); }}class CuboidValue extends CuboidWeight{ double value;s3=length*width*high*density*value; void none() { System.out.println(s3); }}class Demo333{ public static void main(String[] args) { Cuboid cu=new Cuboid(); cu.volume(1.1,1.1,1.1); CuboidWeight cub=new CuboidWeight(); cub.weight(1.1,1.1,1.1,1.1); CuboidValue cubo=new CuboidValue(); cubo. none(1.1,1.1,1.1,1.1,1.1); System.out.println(s1); System.out.println(s2); System.out.println(s3); }}
刚学,勿喷。。。。 展开
s1=length*width*high; void volume() { System.out.println(s1); } }class CuboidWeight extends Cuboid{ double density; s2=length*width*high*density; void weight() { System.out.println(s2); }}class CuboidValue extends CuboidWeight{ double value;s3=length*width*high*density*value; void none() { System.out.println(s3); }}class Demo333{ public static void main(String[] args) { Cuboid cu=new Cuboid(); cu.volume(1.1,1.1,1.1); CuboidWeight cub=new CuboidWeight(); cub.weight(1.1,1.1,1.1,1.1); CuboidValue cubo=new CuboidValue(); cubo. none(1.1,1.1,1.1,1.1,1.1); System.out.println(s1); System.out.println(s2); System.out.println(s3); }}
刚学,勿喷。。。。 展开
4个回答
展开全部
s1=length*width*high;运算要放到方法体内,还有属性私有化之后不能被继承,除了Cuboid类本身,其他类都没法直接访问到
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你把属性设置为私有的 不能继承
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐于2017-05-23
展开全部
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();
}
}
{
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();
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询