Gr_gr 2017-03-17 07:19 采纳率: 0%
浏览 900

小白求解答 java,为啥会出现这个问题

class Rectangle {
private int width;
private int high;
public Rectangle(){}
public Rectangle(int width,int high){
this.width = width;
this.high = high;
}
public void setWidth(){
this.width = width;
}

public int getWidth(int width){
    return width;
}

public void setHigh(){
    this.high = high;
}

public int getHigh(int high){
    return high;
}

public int getLength(){
    return 2*(width+high);
}

public int getArea(){
    return width*high;
}

}

class Test3_Rectangle {
public static void main(String[] args) {
Rectangle re = new Rectangle();
re.setWidth(30);

re.setHigh(40);
System.out.println("周长为"+re.getLength()+" "+"面积为"+re.getArea());
}
}
图片说明

  • 写回答

7条回答 默认 最新

  • MR-yiLuo 2017-03-17 07:24
    关注

    图片说明

    实体类的get set方法错误, get方法一般不带参只有set方法带参

    评论

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料