package test;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;
import javax.swing.Timer;
public class test01 {
public static void main(String[] args){
}
}
class TalkingClock1{
public void start(int interval,final boolean beep){
ActionListener listener=new ActionListener();//Cannot instantiate the type ActionListener
{
public void actionPerformed(ActionEvent e){//void is an invalid type for the variable actionPerformed
Date now=new Date();
System.out.println("At this tone,the time is "+now);
if(beep)Toolkit.getDefaultToolkit().beep();
}
}
Timer t=new Timer(interval,listener);
t.start();
}
}
特别要说说怎么改,是放在新的package里的!
------解决方案--------------------
ActionListener listener=new ActionListener();
这一行应该没分号。
------解决方案--------------------
看3喽