老师帮忙看看哪里需要改进
来源:2-9 编程练习
qq_你答我我就打你_0
2017-11-02 21:56:20
public class Monkey {
String name;
String feature;
public Monkey(){
System.out.println("我是使用无参构造产生的猴子:");
this.name="长尾猴";
this.feature="尾巴长";
}
public Monkey(String name,String feature){
this.name=name;
this.feature=feature;
System.out.println("我是使用带参构造产生的猴子:");
}
}public class MonkeyTest {
public static void main(String[] args) {
Monkey one=new Monkey();
System.out.println("名称:"+one.name);
System.out.println("特征:"+one.feature);
System.out.println("=================================");
Monkey two=new Monkey("白头叶猴","头上有白毛,喜欢吃树叶");
System.out.println("名称:"+two.name);
System.out.println("特征:"+two.feature);
}
}1回答
代码没有问题,继续加油!祝学习愉快!
相似问题