public class Square{
public static void main(String[] args){
private double a;
private double b;
Square(double a,double b){
this.a = a;
this.b = b;
}
public double getHeight(){
return a;
}
public double getBase (){
return b;
}
public double Area(){
double s1=(a*b)*1/2;
return s1;
}
}
}
报错内容如下:
Square.java:3: 错误: 非法的表达式开始
private double a;
^
Square.java:21: 错误: 需要 class、interface、enum 或 record
}
^
2 个错误