File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error in System.out.printf format

 
Jas Oberai
Ranch Hand
Posts: 231
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Kenneth Albertson
Ranch Hand
Posts: 59
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your format string doesn't match the list of arguments that you want to pass to it.
 
Jas Oberai
Ranch Hand
Posts: 231
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,
I tried this :

But still gettin this error:

please tell me friends,how to get rid of this.
Thanks
 
Kenneth Albertson
Ranch Hand
Posts: 59
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic