秒到小时,分钟,秒

时间:2015-01-24 02:39:30

标签: java

我刚刚开始学习java,我有一个似乎只有简单答案的问题......

System.out.print("Your time in hours/minutes/seconds is: "); System.out.print(+hours); System.out.print(":"); System.out.print(+minutes); System.out.print(":"); System.out.print(+seconds);

如何在一行代码中获取最终产品而不会出现编译错误? 我试过了

System.out.println("Your time in hours/minutes/seconds is: " +hours ":" +minutes ":" +seconds ":");

1 个答案:

答案 0 :(得分:1)

您缺少一些串联+运算符。这样做:

System.out.println("Your time in hours/minutes/seconds is: " + hours + ":" + minutes + ":" + seconds + ":");