码迷,mamicode.com
首页 > 其他好文 > 详细

内部类调用

时间:2020-03-02 14:22:19      阅读:61      评论:0      收藏:0      [点我收藏+]

标签:main   oid   pre   int   static   code   this   ring   turn   

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 内部类必须是由主类调用的!!!!!

内部类调用

标签:main   oid   pre   int   static   code   this   ring   turn   

原文地址:https://www.cnblogs.com/zxrxzw/p/12395395.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!