public class RectApp{
double length, width;
public double Rect(double l,double w){
return l=length;
return w=width;
}
public double RectArea(){
return length*width;
}
public double zhouhang(){
return 2*length*width;
}
public static void main(String[] args){
double l=Double.parseDouble(args[0]);
double w=Double.parseDouble(args[1]);
RectApp a=new RectApp();
System.out.println("长方形的面积为:"+a.RectArea());
System.out.println("长方形的周长为:"+a.zhouhang());
}
}为什么不可以运行呢?
double length, width;
public double Rect(double l,double w){
return l=length;
return w=width;
}
public double RectArea(){
return length*width;
}
public double zhouhang(){
return 2*length*width;
}
public static void main(String[] args){
double l=Double.parseDouble(args[0]);
double w=Double.parseDouble(args[1]);
RectApp a=new RectApp();
System.out.println("长方形的面积为:"+a.RectArea());
System.out.println("长方形的周长为:"+a.zhouhang());
}
}为什么不可以运行呢?
public class RectApp{
private double length, width;
public RectApp(double l,double w){ //构造方法
this.length = l;
this.width = w;
} public double RectArea(){
return length*width;
} public double zhouhang(){
return 2*length*width;
} public static void main(String[] args){
double l=Double.parseDouble(args[0]);
double w=Double.parseDouble(args[1]);
RectApp a = new RectApp(l, w);
System.out.println("长方形的面积为:"+a.RectArea());
System.out.println("长方形的周长为:"+a.zhouhang());
}
}
double l=Double.parseDouble(args[0]);
double w=Double.parseDouble(args[1]);
下标这里有问题还有问题?该怎么去修改呢?