• 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

Help people ! i dont what is formating in java

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hai as i said in subject line i dont know what is formating ! how to perform
and i have problem in the below code


System.out.printf( "%5d: ", 100 );
if i remove the "%5d" i get a error ! why i cant print a 100 value !
and i wonder whats is "'%5" , "%d" ...
 
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch

Take a look at this API for more information.
http://java.sun.com/javase/6/docs/api/java/util/Formatter.html#syntax
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Again, welcome.

Look in the Java Tutorials and click on formatting numeric print output for more useful information.
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The %5d bit means "a D-ecimal whole number taking 5 spaces with right justification."
 
Matt Swaggi
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HAY THANK U GUYZ BUT STILL CONFUSION ! FRNDZ
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please use real words when posting to the forums. Abbreviations such as "u" in place of "you" only serve to make your posts more difficult to read and less likely to generate useful responses. Please read this for more information.

Also, please refrain from posting in all uppercase. Please read this for more information.

thanks,
bear
JavaRanch sheriff
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Campbell Ritchie:
The %5d bit means "a D-ecimal whole number taking 5 spaces with right justification."



What part of this don't you understand?
 
Marilyn de Queiroz
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by GUNA RANJAN:
System.out.printf( "%5d: ", 100 );
if i remove the "%5d" i get a error ! why i cant print a 100 value !



I think if you only want to print "100", you would be better to use System.out.println; rather than printf
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic