java 内部类 用法

版权声明:随便转载了.............. https://blog.csdn.net/lijingshan34/article/details/78270359
package com.jingshan;

import com.jingshan.Person.Student1;
import com.jingshan.Person.Student2;
import com.jingshan.Person.Student3;

public class Person {
    public static void main(String[] args) {
        Person p = new Person();
        Student1 s1 = p.new Student1();
        Student2 s2 = p.new Student2();
        Student3 s3 = p.new Student3();
        Student4 s4 = p.new Student4();
        Student5 s5 = new Student5();
    }
    public class Student1{
        public Student1() {
            System.out.print("s1");
        }
    }
    class Student2{
        public Student2() {
            System.out.print("s2");
        }
    }
    protected class Student3{
        public Student3() {
            System.out.print("s3");
        }
    }
    private class Student4{
        public Student4() {
            System.out.print("s4");
        }
    }
    static class Student5{
        public Student5() {
            System.out.print("s5");
        }
    }


}

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试