代码如下:
class Person
{
private String name="haha";
private int age;
private static String country="cn";
Person(String name,int age)
{
this.name=name;
this.age=age;
}
<span style="white-space:pre"> </span>//构造代码块的运用
{
System.out.println(this.name+"..."+this.age);
}
public void setName(String name)
{
this.name=name;
}
public void spreak()
{
System.out.println(this.name+"..."+this.age);
}
public static void showCountry()
{
System.out.println("country="+country);
method();//静态成员方法可以调用静态成员方法
}
public static void method()
{
System.out.println("method run");
}
}
class PersonDemo11
{
public static void main(String[] args)
{
Person p=new Person("张三",20);
p.setName
}
}