P249页,编译器会给外围类添加access$0方法
但是我用java17的javap指令发现外围类没有这个方法为什么啊?
package innerClass;
import java.util.Date;
import javax.swing.JOptionPane;
public class InnerClassTest {
public static void main(String[] args) {
TalkingClock clock= new TalkingClock(1000,true);
clock.start();
JOptionPane.showMessageDialog(null, "quit program?");
System.exit(0);
}
}
package innerClass;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;
import javax.swing.Timer;
public class TalkingClock {
private int interval;
private boolean beep;
public TalkingClock(int interval, boolean beep) {
this.interval = interval;
this.beep = beep;
}
public void start()
{
//TODO
ActionListener listener=new TimePrinter();
Timer t=new Timer(interval, listener);
t.start();
}
public class TimePrinter implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("At the tone,the time is "+new Date());
if (beep)Toolkit.getDefaultToolkit().beep();
}
}
}