wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Error in System.out.printf format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error in System.out.printf format" Watch "Error in System.out.printf format" New topic
Author

Error in System.out.printf format

Jas Oberai
Ranch Hand

Joined: Jan 16, 2005
Posts: 231
hi friends,
I want to print String,String,int,int,int,int,double data from a file,for which I am using this syntax:

can someone please tell me the write format to print them.
Thanks


SCJP 1.4 (88%)<br />SCWCD 1.4 (88%)
Kenneth Albertson
Ranch Hand

Joined: Sep 18, 2005
Posts: 59
Your format string doesn't match the list of arguments that you want to pass to it.
Jas Oberai
Ranch Hand

Joined: Jan 16, 2005
Posts: 231
Thanks,
I tried this :

But still gettin this error:

please tell me friends,how to get rid of this.
Thanks
Kenneth Albertson
Ranch Hand

Joined: Sep 18, 2005
Posts: 59
Originally posted by jas oberai:
I tried this :
System.out.printf( "%s %s %s %d %d %d %f \n",....)
for String,String,String,int,int,int,double

If you actually had passed those arguments to that format string, jas, it would have worked, so I don't think you did. My guess is that the 4th arg you passed was a string, which is what caused the error message "d != java.lang.String", meaning that a "d" format specifier can't deal with a string. So I repeat:

Your format string doesn't match the list of arguments that you are passing to it.

If you still can't get it to work, show us the complete printf statement, so we can see what args you are actually passing, not just what args you think you are passing.
[ October 10, 2005: Message edited by: Kym Thompson ]
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061

This is not correct Java syntax and will not even compile. I assume that you put "...." instead of what you REALLY have here. We need to see ALL the arguments that you have left out in order to help you. The format String is just fine, IF THE OTHER ARGUMENTS MATCH. We can't help you understand why they don't match unless you show us what the other arguments ARE.

Layne


Java API Documentation
The Java Tutorial
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error in System.out.printf format