本帖最后由 张向辉 于 2013-2-3 11:25 编辑
class Person
{
private String name;
private String age;
{
cry();
//System.out.println("name="+name+",,age="+age);
}
Person()
{
System.out.println("A:name="+name+",,age+"+age);
}
Person(String n)
{
name = n;
// cry();
System.out.println("b:name="+name+",,age="+age);
}
Person(String n,String a)
{
name = n;
age = a;
// cry();
System.out.println("c:name="+name+" ,,age="+age);
}
int cry()
{
System.out.println(2);
}
}
class PersonDemo2
{
public static void main(String[] args)
{
Person p1 = new Person();
Person p2 = new Person("lisi");
Person p3 = new Person("wangwu","String");
}
}
|