A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© nixing 中级黑马   /  2015-7-8 23:31  /  631 人查看  /  2 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

谁能帮我解释一下这个代码的意思啊
interface Inter
{
         void method();
}
class Test
{
         static Inter function()
         {
          return new Inter()
                 {
                        public void method()
                         {
                                System.out.println("adsfadfadf");
                         }
                 } ;
         }
}

class  Noname5
{
        public static void main(String[] args)
        {
                Test.function().method();
        }
}

2 个回复

倒序浏览
Test.function这个调用Test的function静态方法返回得到一个Inter对象,再调用内部类实现的method方法,可以这样理解吧?希望能帮到你
回复 使用道具 举报
娜妞子~ 来自手机 中级黑马 2015-7-9 13:24:07
藤椅
nixing 发表于 2015-7-8 23:31
谁能帮我解释一下这个代码的意思啊
interface Inter
{

马上就要学这个啦
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马