1\匿名内部类是否可以继承其它类?
2\匿名内部类是否可以实现接口?

解决方案 »

  1.   

    汗匿名的内部类是没有名字的内部类。不能extends(继承) 其它类,但一个内部类可以作为一个接口,由另一个内部类实现。 
      

  2.   

    都可以
    // 继承 JFrame 并重写 setVisible 方法
    new JFrame("abcde") {
    public void setVisible(boolean b) {
    if (b) {
    this.setSize(320, 100);
    System.out.println("我要显示了!!!");
    }
    super.setVisible(b);
    }
    }.setVisible(true);
    JButton btn = new JButton("按钮");// ActioinListener 就是一个接口
    ActionListener listener = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    System.out.println("点击了" + e.getActionCommand());
    }
    };
    btn.addActionListener(listener);
      

  3.   


    谁说不能继承啊?public class Test
    {
        public static void main(String[] args)
        {
            Thread t = new Thread(){
               public void run()
               {
                    System.out.println("Hello, World");
               }
             };
            t.start();
        }
    }
      

  4.   


    谁说不能继承啊?public class Test
    {
        public static void main(String[] args)
        {
            Thread t = new Thread(){
               public void run()
               {
                    System.out.println("Hello, World");
               }
             };
            t.start();
        }
    }
      

  5.   


    错了,发现在swing编程的时候一直在使用
      

  6.   

    来晚了~楼上说完了~
    of course bingo~