这是我的代码:
int hoursFormat = 1, minsFormat = 2, secsFormat = 3;
String timeFormat = String.format("%02d:%02d:%02d",hoursFormat, minsFormat, secsFormat);
这会产生编译错误:
Unresolved compilation problem:
The method format(String, Object[]) in the type String is not applicable for the
arguments (String, int, int, int)
为什么我会在这里收到此错误以及如何修复它?
我对 printf 也有类似的问题。我使用的是 JDK 1.6.0_27。将合规级别设置为 1.6 解决了我的问题。可以通过以下方式进行设置。
项目 > 属性 > Java 编译器
您还可以参考以下主题:
为什么我使用简单的 printf 会出现编译错误? https://stackoverflow.com/questions/7774428/why-am-i-getting-a-compilation-errors-with-a-simple-printf
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)