内部类调用

public class DotThis {
    
    //内布类
    public class Inner {    
        public int outer(int a ,int b) {
            return a+b;
        };    
    }

    //调用内部类
    public static void main(String[] args) {
        Inner inner = new DotThis().new Inner();
        System.out.print(inner.outer(1, 2));
} }

在main函数里面调用new 内部类必须是由主类调用的!!!!!

posted @ 2020-03-02 14:12  旺旺a  阅读(292)  评论(0编辑  收藏  举报