• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

Help people ! i dont what is formating in java

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • 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
  • 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: 66484
251
  • Mark post as helpful
  • send pies
  • 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: 66484
251
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
HAY THANK U GUYZ BUT STILL CONFUSION ! FRNDZ
 
Marshal
Posts: 67313
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • 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: 9099
12
  • Mark post as helpful
  • send pies
  • 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: 9099
12
  • Mark post as helpful
  • send pies
  • 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
 
Try 100 things. 2 will work out, but you will never know in advance which 2. This tiny ad might be one:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!