Connecting Tech Pros Worldwide Forums | Help | Site Map

Printf question

Newbie
 
Join Date: Jul 2008
Posts: 3
#1: Jul 31 '08
Hi!!!
could somebody plzzzzz tell me why i have an error for this simple code?


int n=5;

System.out.printf("%d",n);

i keep getting this message

xception 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)


im really confused it used to work with me all the time but now i just re-installed java eclipse and i think its an installation problem, i dont know

thanks in advance
Member
 
Join Date: Jul 2008
Posts: 53
#2: Jul 31 '08

re: Printf question


Which version of Eclipse are you running?
What is version is Compiler compliance set to?
Newbie
 
Join Date: Jul 2008
Posts: 3
#3: Jul 31 '08

re: Printf question


im using version 3.1
i've used it before and it was ok
the only difference when i re-installed it is that im using windows vista now and i used to have windows xp
also i used to have it in c/program files directory and now i have it in D directory

do these things make a difference??
Member
 
Join Date: Jul 2008
Posts: 53
#4: Jul 31 '08

re: Printf question


Eclipse needs to be able to see the Java 5.0 files (which it may not be able to now that they have been moved to d:

Make sure Eclipse is pointing to the correct version of Java -> it sounds like you might be picking up an older version of java (again, possibly because you moved the newer one)


You could pass the integer as a (new) Array {val}, or you could use java's print rather than printf - but this hides the problem rather than fixing it....
Newbie
 
Join Date: Jul 2008
Posts: 3
#5: Aug 13 '08

re: Printf question


thanx alot i just fixed the problem :)
it was just like what u said
thanks again
Reply


Similar Java bytes