package com.object.project;
public class Monkey {
//成员属性
String name;
String festure;
//成员方法
public Monkey() {
System.out.println("我是使用无参构造产生的猴子:");
}
public Monkey(String name,String feature) {
this.name=name;
this.festure=feature;
System.out.println("我是使用带参构造产生的猴子:");
}
public class Monkey {
//成员属性
String name;
String festure;
//成员方法
public Monkey() {
System.out.println("我是使用无参构造产生的猴子:");
}
public Monkey(String name,String feature) {
this.name=name;
this.festure=feature;
System.out.println("我是使用带参构造产生的猴子:");
}
}
public class MonkeyTest {
public static void main(String[] args) {
//实例化对象
Monkey good=new Monkey();
//测试
good.name="长尾猴";
good.festure="尾巴长";
System.out.println("名称:"+good.name);
System.out.println("特征:"+good.festure);
System.out.println("================================");
//实例化对象
Monkey bad=new Monkey("白头叶猴","头上有白叶,喜欢吃树叶");
//测试
System.out.println("名称:"+bad.name);
System.out.println("特征:"+bad.festure);
}
}