本文介紹了String 類型中的方法 format(String, Object[]) 不適用于參數 (...)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
這是我的代碼:
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)
為什么會出現此錯誤,我該如何解決?
Why am I getting this error here and how can I fix it?
推薦答案
我遇到了類似的 printf 問題.我正在使用 JDK 1.6.0_27.將合規級別設置為 1.6 解決了我的問題.這可以通過以下方式設置.
I had a similar problem with printf. I am using JDK 1.6.0_27. Setting the compliance level to 1.6 solved my issue. This can be set in the following way.
項目 > 屬性 > Java 編譯器
Project > Properties > Java Compiler
你也可以參考下面的帖子:
You can also refer to the following thread:
為什么會出現編譯錯誤用一個簡單的 printf?
這篇關于String 類型中的方法 format(String, Object[]) 不適用于參數 (...)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!