我刚刚开始学习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 ":");
答案 0 :(得分:1)
您缺少一些串联+
运算符。这样做:
System.out.println("Your time in hours/minutes/seconds is: " + hours + ":" + minutes + ":" + seconds + ":");