Sign in to follow this  
iccaros

Another Java Question :)

Recommended Posts

ok I have a simple java program but I don't understand why I get this error on printf

here is the center of my program

 int output;

//take user input
System.out.print("Enter the first number: ");
userInput1 = input.nextInt();

System.out.print("Enter the second number: ");
userInput2 = input.nextInt();

System.out.print("Enter The Third number: ");
userInput3 = input.nextInt();

output = sumNumbers(userInput1,userInput2,userInput3);
System.out.printf("the Sum of your numbers = %d\n",output);

the error is

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

but all the examples on the web show this format??

thanks

Share this post


Link to post
Share on other sites

Is the compiler in Java 1.5 mode? It looks like it isn't autoboxing the int.

Share this post


Link to post
Share on other sites
Is the compiler in Java 1.5 mode? It looks like it isn't autoboxing the int.

Must not be, I can compile this:

public class test
{
public static void main(String[] args)
{
int output = 9;
System.out.printf("the Sum of your numbers = %d\n",output);
}
}

fine with 1.5(sun), but not with 1.4(blackdown).

Edited by naraku9333

Share this post


Link to post
Share on other sites

I just compiled with command line javac no problem.. but eclipse gives this error..

it is java 1.5 so it must be a missconfig of eclipse

will try agian..

thanks..

Share this post


Link to post
Share on other sites

I dont know about eclipse, but other IDE's Ive used (JBuilder and JStudio) defaulted to a 1.4 sdk installed in the applications directory, I had to specify my 1.5 jdk.

Share this post


Link to post
Share on other sites

Thanks for the input..

I updated eclipse to 3.11 and now I have to option to default to 1.5

Thanks.. this has been driving me nuts for two days now..

Share this post


Link to post
Share on other sites
I dont know about eclipse, but other IDE's Ive used (JBuilder and JStudio) defaulted to a 1.4 sdk installed in the applications directory, I had to specify my 1.5 jdk.

does jbuilder or jstudio have a gui builder??

Share this post


Link to post
Share on other sites

I'm fairly sure they do (in fact I am sure jstudio does), I just haven't learned anything about gui's yet (first semester java class). Both are free but require registering to download. Also on the sun developer network downloads page they have three IDE's I believe (jstudio, creator and studio 11).

Edited by naraku9333

Share this post


Link to post
Share on other sites

(first semester java class)

me too, this is my second to last semester before I graduate. I left my programing classes till last

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this