Java Error非法启动表达式

时间:2015-03-26 13:46:35

标签: java illegalstateexception

这是我的代码:

import java.util.Calendar;

public class Time {
    private int hour;
    private int minute;
    private int second;

    public static void main (String args[]){
        Time time1 = new Time();
        Time time2 = new Time();

        time2.setTime(555550000L);

        System.out.println("First Time: "+time1.hour+":"+time1.minute+":"+time1.second+);
        System.out.println("Second Time: "+time2.hour+":"+time2.minute+":"+time2.second+);
    }

    public Time() {
        Calendar calen= Calendar.getInstance();
        hour=calen.get(Calendar.HOUR_OF_DAY);
        minute=calen.get(Calendar.MINUTE);
        second=calen.get(Calendar.SECOND);
    }

    public void setTime(long elapseTime){
        Calendar c=Calendar.getInstance();
        c.setTimeInMillis(elapseTime);
        hour=c.get(Calendar.HOUR_OF_DAY);
        minute=c.get(Calendar.MINUTE);
        second=c.get(Calendar.SECOND);
    }
}

我一直收到以下错误,但我不知道如何修复它们。救命?

  • Time.java:14:非法开始表达 System.out.println("第一次:" + time1.hour +":" + time1.minute +":" + time1.second +)

  • Time.java:15:非法开始表达 System.out.println("第二次:" + time2.hour +":" + time2.minute +":" + time2.second +) ;                                                                             ^

2 个答案:

答案 0 :(得分:0)

删除最后的+

System.out.println("First Time: "+time1.hour+":"+time1.minute+":"+time1.second);
System.out.println("Second Time: "+time2.hour+":"+time2.minute+":"+time2.second);

答案 1 :(得分:0)

它是System.out.println行末尾的尾随+。 你必须删除它,一切都会好的。