I just wanted to test something with Javas printf method. Now its been a while since I last used this, so maybe this is now normal behaviour.
This code is an example taken from http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html and Wikipedia.
The thing is, it wont run.
import java.util.Calendar;
public class TestPrintf {
public static void main(String[] args) {
System.out.printf("%s, %s", "Hello", "World!");
// Writes a formatted string to System.out.
System.out.format("Local time: %tT", Calendar.getInstance());
// -> "Local time: 13:34:18"
}
}
Leads to
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The method printf(Locale, String, Object[]) in the type PrintStream is not applicable for the arguments (String, String, String)
The method format(String, Object[]) in the type PrintStream is not applicable for the arguments (String, Calendar)
at TestPrintf.main(TestPrintf.java:7)
I am using Eclipse Version: Mars.2 Release (4.5.2) on Ubuntu with Java version 1.8.0_74.
I know it used to work this way, but now I have to supply an array with the variables? What if I want to format a mix of strings and integers? An Object[] with mixed types cant really be required now can it?
Some insight why this is required/was changed would be appreciated.