gpt4 book ai didi

java - String 类型中的方法 format(String, Object[]) 不适用于参数 (...)

转载 作者:搜寻专家 更新时间:2023-10-30 19:57:25 25 4
gpt4 key购买 nike

这是我的代码:

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 编译器

您也可以引用以下话题:

Why am I getting a compilation errors with a simple printf?

关于java - String 类型中的方法 format(String, Object[]) 不适用于参数 (...),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7701532/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com