亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

java核心編程 書上代碼對著抄一遍出錯,,

java核心編程 書上代碼對著抄一遍出錯,,

慕瓜4170288 2019-08-19 14:38:37
package diliuzhang;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.Date;import java.util.Timer;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); }}class TalkingClock{ private int interval; private boolean beep; public TalkingClock(int interval,boolean beep) { this.interval=interval; this.beep=beep; } public void start() { ActionListener listener=new TimerPrinter(); //構造一個定時器 每個xx毫秒通知 listener一次 Timer t=new Timer(interval,listener); //啟動 t.start(); } public class TimerPrinter implements ActionListener{ public void actionPerformed(ActionEvent event) { System.out.println("At the tone,the time is"+new Date()); if(beep)Toolkit.getDefaultToolkit().beep(); } } }
查看完整描述

2 回答

?
慕瓜4170288

TA貢獻2條經驗 獲得超0個贊

已經解決了,,,導包導錯了。。。干

查看完整回答
反對 回復 2019-08-19
?
慕瓜4170288

TA貢獻2條經驗 獲得超0個贊

public void start() {

ActionListener listener=new TimerPrinter();

//構造一個定時器 每個xx毫秒通知 listener一次

Timer t=new Timer(interval,listener);

//啟動

t.start();

錯誤出在這? 顯示

構造函數 Timer(int, ActionListener)未定義

這怎么給Timer構造函數。。。。

查看完整回答
反對 回復 2019-08-19
  • 2 回答
  • 0 關注
  • 878 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號