Eclipse Error : The method printf(String, Object[]) in the type PrintStream is not applicable for the arguments (String, String, String)

So, my 2nd error to document already.  printf is an alternative to println and can be used to print stuff on the screen.

What’s wrong with this code?

public class ForLoop{

public static void main(String[] args) {

for(int i = 0;i < 10;i++) {
//System.out.println(“The value of i is ” + i);
System.out.printf(“The value of i is %d\n”, i);
// System.out.println();
System.out.printf(“test – %d”, i);

javac.exe compiles it well, but eclipse keeps throwing the nasty error.  So, you know it’s one of Eclipse’s quirky traits and some settings need to be modified. Here are the setting changes required –

java eclipse error

Project -> Properties -> Java Compiler -> Enable Project Specific Settings.

Set Compiler Compliance Level to 1.5

The error vanishes now. Happy Coding! 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s