java编译出错,错误:需要<标识符>,但就是找不到哪错了,求大神指导!!!谢了!!!
这是代码:classCat{Stringcolor;intheight;intweight;Cat(String_color,int_height,int_weight)...
这是代码:
class Cat{ String color; int height; int weight;
Cat(String _color,int _height,int _weight){ color = _color; height = _height; weight = _weight; } void setColor(_color){ color = _color; } void setHeight(_height){ height = _height; } void setWeight(_weight){ weight = _weight; }}
public class TestCat{ public static void main(String[] args){ Cat c = new Cat("yellow",5,4); System.out.println("The Cat:"+c); }} 展开
class Cat{ String color; int height; int weight;
Cat(String _color,int _height,int _weight){ color = _color; height = _height; weight = _weight; } void setColor(_color){ color = _color; } void setHeight(_height){ height = _height; } void setWeight(_weight){ weight = _weight; }}
public class TestCat{ public static void main(String[] args){ Cat c = new Cat("yellow",5,4); System.out.println("The Cat:"+c); }} 展开
3个回答
展开全部
void setColor(_color){
color = _color;
}
void setHeight(_height){
height = _height;
}
void setWeight(_weight){
weight = _weight;
}
里面的参数缺少类型
color = _color;
}
void setHeight(_height){
height = _height;
}
void setWeight(_weight){
weight = _weight;
}
里面的参数缺少类型
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
public void setColor(String color) {
this.color = color;
}
public void setHeight(int height) {
this.height = height;
}
public void setWeight(int weight) {
this.weight = weight;
}
局部变量没有类型 用这个
this.color = color;
}
public void setHeight(int height) {
this.height = height;
}
public void setWeight(int weight) {
this.weight = weight;
}
局部变量没有类型 用这个
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询