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());
}
}为什么不可以运行呢?

解决方案 »

  1.   

    你应该看看构造方法的知识。然后就是一个方法能够同时return两个不同的变量吗?
    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()); 

      

  2.   

    public static void main(String[] args){ 
    double l=Double.parseDouble(args[0]); 
    double w=Double.parseDouble(args[1]); 
    下标这里有问题还有问题?该怎么去修改呢?
      

  3.   

    没有问题吧 你在CMD里运行的时候输入:java RectApp 20.0 30.5然后args[0]=20.0; args[1]=30.5; 这样就好了。