• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error in System.out.printf format

 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic