class Person
{
private String name = "haha";
private int age = 10;
{
System.out.println(name+"***"+age);
name = "hello";
age = 20;
System.out.println(name+"***"+age);
}
public Person(){}
public Person(String name,int age)
{
System.out.println(this.name+"***"+this.age);
this.name = name;
this.age = age;
System.out.println(this.name+"***"+this.age);
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setAge(int age)
{
this.age = age;
}
public int getAge()
{
return age;
}
}
class Test
{
public static void main(String[] args)
{
Person p = new Person("world",30);
System.out.println(p.getName()+"***"+p.getAge());
}
}
|