class Person
02 {
03 private String name ;
04 private int age ;
05 public Person(String n,int a)
06 {
07 name = n ;
08 age = a ;
09 System.out.println("public Person(String n,int a)") ;
10 }
11 public String talk()
12 {
13 return "我是:"+name+",今年:"+age+"岁" ;
14 }
15 }
16
17 public class TestConstruct1
18 {
19 public static void main(String[] args)
20 {
21 Person p = new Person("张三",25) ;
22 System.out.println(p.talk()) ;
23 }
|