在程序中定义一个School类。在School类中定义一个内部类Student,分别创建这两个类的对象,访问两个对象中的方法

class School
{
String name;public class Student
{
String name;
int age;
public Student(String schoolName,String studentName,int newAge){
//将schoolName赋值给School类的name属性
//将studentName赋值给Student类的name属性
//将newAge赋值给Student类的age属性
}
public void output(){
System.out.println(“学校:”+School.this.name);
System.out.println(“姓名:”+this.name);
System.out.println(“年龄:”+this.age);
}
}
public void output(){Student stu =new Student(“金融学院”,”张三”,24);stu.output();
}

public class Inner{public static void main(String[] args){
System.out.println(“--通过外部类成员访问内部类员--”);
School a=new School();
a.output();
System.out.println(“--直接访问内部类成员--”);
School.Student b=a.new Student(“金融学院”,“李”,23);
b.output();
}
}


class School {

    String name;

    public class Student {

        String name;

        int age;

        public Student(String schoolName,String studentName,int newAge){
    //将schoolName赋值给School类的name属性
    //将studentName赋值给Student类的name属性
    //将newAge赋值给Student类的age属性
            School.this.name = schoolName;
            this.name = studentName;
            this.age = newAge;
        }

        public void output(){
            System.out.println("学校:"+School.this.name);
            System.out.println("姓名:"+this.name);
            System.out.println("年龄:"+this.age);
        }
    }
    public void output(){Student stu =new Student("金融学院","张三",24);
        stu.output();
    }

    public static class Inner{
        public static void main(String[] args){
            System.out.println("--通过外部类成员访问内部类员--");
            School a=new School();
            a.output();
            System.out.println("--直接访问内部类成员--");
            School.Student b=a.new Student("金融学院","李",23);
            b.output();
        }
    }
}