class Box
{
// Instance Variables
double length ,ipsos ;
double width ,mikos ;
double height ,platos;
// Constructors
public Box ( double side )
{
width = side ;
height = side ;
length = side ;
}
public Box ( double x , double y , double z)
{
platos = y ;
ipsos = z;
mikos = x ;
}
// Methods
double calculate(double praksi)
{
return 2 * ( width * height +
width * length +
height * length ) ;
}
double volume(double emvadon)
{
return platos*ipsos*mikos ;
}
@Override
public String toString() {
return "Volume: " + volume(1) + "\n Calculate: " + calculate(1);
}
public class Cube extends Box {
public Cube(double side) {
super(side, side, side);
if (side<0) { System.out,println("lathos timi);}
}
}
}
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,编译器在此找到错误:if(side <0){System.out,println("lathos timi);}
它说:不是声明
怎么了?我是java编程的新手,但现在关于来自C的'if'.
你的println语句中有一个逗号.它应该是:
System.out.println("lathos timi");
Run Code Online (Sandbox Code Playgroud)