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

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 詹继强 中级黑马   /  2013-12-15 18:41  /  850 人查看  /  2 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

本帖最后由 詹继强 于 2013-12-15 19:37 编辑

interface Inner
{
        void method();
}
class Test
{
        static Inter function()
        {
                return new Inter()
                {
                        public void method()
                        {
                                System.out.println("method run");
                        }
                };
        }
}
class InnerClssTest
{
        public static void main(String[] args)
        {
                Test.function().method();
        }
}
这样写为什么会提示编译失败呢?请各位帮小弟解惑!

评分

参与人数 1黑马币 +3 收起 理由
乔兵 + 3

查看全部评分

2 个回复

倒序浏览
class Test
{
        static Inter function()//    Inter 修改成   Inner   
        {
                return new Inter()
                {
                        public void method()
                        {
                                System.out.println("method run");
                        }
                };
        }
}

评分

参与人数 1技术分 +1 收起 理由
简★零度 + 1

查看全部评分

回复 使用道具 举报
Faner 发表于 2013-12-15 19:17
class Test
{
        static Inter function()//    Inter 修改成   Inner   

原来是类名弄错了!谢谢!
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马