import java.util.*;
public class Reminder2
{
Timer timer;
Calendar calendar = new Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 3);
calendar.set(Calendar.MINUTE, 1);
calendar.set(Calendar.SECOND, 0);
Date times = calendar.getTime();
public Reminder2()
{
timer = new Timer();
timer.schedule(new RemindTask(), times);
}
class RemindTask extends TimerTask
{
public void run()
{
System.out.println( "Time 's up! ");
timer.cancel();
}
}
public static void main(String[] args)
{
new Reminder2();
System.out.println( "Task scheduled ");
}
}
不知道这个程序在编译时总出现calendar.set(Calendar.HOUR_OF_DAY, 3);
calendar.set(Calendar.MINUTE, 1);
calendar.set(Calendar.SECOND, 0);
需要标识符的错误提示,而且我查了资料,set确实是Calendar类的一个方法啊,希望各位高手指点指点,我查了很多资料也不知道错在哪里了?
------解决方案--------------------
楼主,这些
calendar.set(Calendar.HOUR_OF_DAY, 3);
calendar.set(Calendar.MINUTE, 1);
calendar.set(Calendar.SECOND, 0);
Date times = calendar.getTime();
应该写在方法里面才行啊。
------解决方案--------------------
Calendar calendar = new Calendar.getInstance();
===================================================
这一句太明显接下来的三句一看就是C语言的架势.不过也不对阿,C的语句也应该放到方法里面吧
------解决方案--------------------
calendar.set(Calendar.HOUR_OF_DAY, 3);
calendar.set(Calendar.MINUTE, 1);
calendar.set(Calendar.SECOND, 0);
这个是这样用的..
就是new Calendar.getInstance();不对
不要那个new...