本帖最后由 花开花落总相似 于 2013-5-30 10:36 编辑
- class Person //毕老师的验证代码
- {
- private String name;
- private int age;
- Person(int age)
- {
- this.age = age;
- }
- Person(String name)
- {
- this.name = name;
- }
- Person(String name,int age)
- {
- this.name = name;
- this.age = age;
- }
- public void speak()
- {
- System.out.println("name="+this.name+"...age="+this.age);
- this.show();
- }
- public void show()
- {
- System.out.println(this.name);
- }
- }
- class PersonDemo3
- {
- public static void main(String[] args)
- {
- Person p = new Person("lisi");
- Person p1 = new Person("zhangsan");
- p.speak();
- p1.speak();
- p.speak();
- }
- }
复制代码 |