private class TimePrinter implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
Date now = new Date();
System.out.println("At the tone, the time is " + now);
if (beep)
Toolkit.getDefaultToolkit().beep();
}
}
}
复制代码
局部内部类不能用public或private进行声明,其作用域被限定在声明这个局部类的块中。
局部类可以访问局部变量,前提是局部变量被声明为final。
匿名内部类的语法格式为:
new SuperType(construction parameters)
{
inner class methods and data
}
匿名类不能有构造器,在实现接口的时候,不能有构造参数。