Black Swan
Black Swan

Reputation: 853

eclipse luna format printing

I have downloaded eclipse Luna. But the format printing is not working. let consider the simple code given below:

public class Test {
    public static void main(String args[]) {
        int a=4;
        System.out.printf("%d",a);
    }
}

It is showing error message below:

Exception in thread "main" java.lang.Error: Unresolved compilation problem: The method printf(String, Object[]) in the type PrintStream is not applicable for the arguments (String, int)

What may be the possible cause and solution?

Upvotes: 1

Views: 437

Answers (4)

Black Swan
Black Swan

Reputation: 853

i have got my answer from the comment of @Katja Christiansen. the comment has given below, as @Katja Christiansen not write the solution in asnswer for that i am wrriting it here let other can find that the problem has solved..

"Maybe project specific compiler settings are enabled? Open the properties of your Java project, select "Java Compiler" and check if "Enable project specific settings" is enabled and if the selected JDK differs from the Eclipse JDK settings. – Katja Christiansen "

after trying it, the printf has solved and it solved for all the existing project.

Thanks @Katja Christiansen for ur cooperation.

Upvotes: 2

Gerralt
Gerralt

Reputation: 221

Your Compiler compliance level might not be correct.

You can find it in Eclipse here: Project > Properties > Java Compiler

Make sure it's set to 1.5 or higher.

Upvotes: 2

Malik Brahimi
Malik Brahimi

Reputation: 16721

Try using the format method:

int a = 4;
System.out.format("%d", a);

Upvotes: 0

Mike Elofson
Mike Elofson

Reputation: 2037

I'm using Eclipse Luna and the following main method runs for me:

public class StackOverflow {

    public static void main(String[] args) {
        int a = 4;
        System.out.printf("%d", a);
    }

}

Gives me the output of:

4

Upvotes: 0

Related Questions