class Person
{
private String name;
private int age;
{
System.out.println("person.cord.run");
}
Person()
{
System.out.println("A:name="+name+",,age="+age);
//System.out,println("cry");
cry();
}
Person(String n)
{
name =n;
System.out.println("A:name="+name+",,age="+age);
//System.out,println("cry");
cry();
}
public void setName(String n)
{
name =n;
}
public void getName(String n)
{
return n;
}
Person(String n,int a)
{
name=n;
age=a;
System.out.println("A:name="+name+",,age="+age);
//System.out.println("cry");
cry();
}
public static void cry()
{
System.out.println("cry......");
}
}
class PersonDemo2
{
public static void main(String[] args)
{
Person p1=new Person();
Person p2=new Person("lisi");
p1.cry();
}
}
//按照老师讲的写的,可为什么显示 仅当显示请求注释处理时才接受类名称Person??? |
|