• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help people ! i dont what is formating in java  RSS feed

 
Matt Swaggi
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" ...
 
Freddy Wong
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
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • 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: 56536
172
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66306
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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
 
Marilyn de Queiroz
Sheriff
Posts: 9082
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: 9082
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!