重载方法吃

public class Person {
String name;
int age;

void eat(){
    System.out.println(name+"正在吃");
}
void eat(String food){
    System.out.println(name+"正在吃"+food);
}
void eat(String food,int number){
    System.out.println(name+"正在吃"+number+"个"+food);
}

}
public class Test{
    public static void main(String[] args) {
Person p=new Person();
p.name="郑飞";
p.age=18;
p.eat("烤冷面");
p.eat("烤肠", 2)    ;    
p.eat();        
}
}

 

posted @ 2017-04-09 14:44  苏轼的红烧肉  阅读(96)  评论(0编辑  收藏  举报