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());
}
}
实体类的get set方法错误, get方法一般不带参只有set方法带参
说的是你的set方法没有参数,结果你调用的时候传入了参数;
你看看你写的,set那里确实没有参数,反而get有参数;
你应该是把set里面的参数错写到get了;
改过来就可以了;
希望可以帮到你....
set差参数,兄弟我升三级还差两个积分
哥们,你获取数据还带参数干什么......
好好检查下你的类方法 看看一致不一致
调用你自己写的get,set方法时错误,有参无参要看清,新手建议可以右键source,直接用快捷方式写出,如有需求可以再修改
public void setWidth(int width){
this.width = width;
}
就好了