测试

 1 //Person类定义
 2 public class Person {
 3     private String name;
 4     private int age;
 5 
 6     public Person() {
 7     }
 8 
 9     public Person(String name, int age) {
10         this.name = name;
11         this.age = age;
12     }
13 
14     public String getName() {
15         return name;
16     }
17 
18     public void setName(String name) {
19         this.name = name;
20     }
21 
22     public int getAge() {
23         return age;
24     }
25 
26     public void setAge(int age) {
27         this.age = age;
28     }
29 
30     void eat(String food) {
31         System.out.println("eat " + food);
32     }
33 
34     protected void drink(String drink) {
35         System.out.println("drink " + drink);
36     }
37 
38     @Override
39     public String toString() {
40         // TODO Auto-generated method stub
41         return ("name: " + name + "age: " + age);
42     }
43 }
Person类定义

 

posted @ 2018-04-04 15:06  LAL248  阅读(137)  评论(0编辑  收藏  举报