import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.Timer;
public class Test
{
public static void main(String[] args)
{
ActionListener listener=new TimePrinter();
Timer t=new Timer(10000,listener);
t.start();
JOptionPane.showMessageDialog(null,"Quit program?");
System.exit(0);
}
}
class TimePrinter implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
Date now=new Date();
System.out.println("At the tone, the time is "+now);
Toolkit.getDefaultToolkit().beep();
}
}
接口与抽象类的区别在于接口可以使用多个,但只能扩展一个抽象类. 而C++中存在多继承
阅读(2817) | 评论(1) | 转发(0) |