Alex Rivera | Logout

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

Asked 2011-10-09T04:57:48.663
14

Here is my code:

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

This gives a compilation error:

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?

Edit
Report

1 Answer

2

Are you using Java version 1.4 or below? Autoboxing wasn't introduced until Java 5. Try manually boxing ints to Integers.

answered 2012-09-11T18:55:53.553

Your Answer