/*
需求:定义一个内部类,一个外部类,用内部类调用外部类的方法,以及修改外部类的属性
*/
class Person
{
private String name;
private int age;
private void play()
{
System.out.println("wan");
}
class Student
{
public static void setName(name)
{
this.name=name;
}
public static String getName()
{
return name;
}
public static void setAge(age)
{
this.age=age;
}
public static int getAge()
{
return age;
}
play();
}
public static void main(String[] args)
{
Student s=new Student();
s.setName("zhangsan");
s.getName();
s.setAge(18);
s.getAge();
s.play;
//System.out.println("Hello World!");
}
} |
|