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

© liyudong 中级黑马   /  2016-11-13 23:16  /  1261 人查看  /  5 人回复  /   2 人收藏 转载请遵从CC协议 禁止商业使用本文

public class S1 {
       
        String s = "S1";
        public void display(){
                System.out.println(s);
                System.out.println(this.s);
        }
}

public class S2 extends S1{
       
        String s = "S2";
       
}

public class Demo {       
       
        static  String s = "Outer";       
       
        public static void main(String[] args) {
                S2 s2 = new S2();
                display();
                s2.display();
        }
       
        public static void display(){
                S2 s2 = new S2();
                System.out.println(s);
                System.out.println(s2.s);
        }
       
}

5 个回复

倒序浏览
楼主这个可以编译通过?
来自宇宙超级黑马专属苹果客户端来自宇宙超级黑马专属苹果客户端
回复 使用道具 举报
回复 使用道具 举报
挺经典的!!Outer S2 S1 S1
回复 使用道具 举报
回复 使用道具 举报
一个源文件中只能有一个公共类,打印就是
Outer
S2
S1
S1
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马