The method format(String, Object[]) in the type String is not applicable for the arguments (…)

后端 未结 6 1563
耶瑟儿~
耶瑟儿~ 2020-11-28 14:27

Here is my code:

int hoursFormat = 1, minsFormat = 2, secsFormat = 3;
String timeFormat = String.format(\"%02d:%02d:%02d\",hoursFormat, minsFormat, secsForma         


        
6条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-28 15:13

    Are you using eclipse?

    If so sometimes, issues like this appear, when everything seems to be correct. Here is how I just solved it:

    • Right click on project and go to properties->Java Compiler
    • You would be seeing a recent Compiler compliance level (1.7 in my case) set in the drop down ("compiler compliance level"). Also same version is seen set below in "Generated .class files compatibility" and "Source compatibility".

    Now:

    • Select the Checkbox: "Use default compliance settings"
    • Notice that a lower version (in my case 1.1) got set for: "Generated .class files compatibility" and "Source compatibility". This is the issue, although eclipse is showing that it is compiling using a higher compiler it is not.
    • In the drop down "compiler compliance level" choose some other level and then select the one you want. The changes would be reflected below in "Generated .class files compatibility" and "Source compatibility".

    This should have resolved the issue.

提交回复
热议问题