This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Having 001, 002, etc rather than 1, 2  RSS feed

 
Ryan Akim
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


See, I need every "|" to line up with each other, it just looks better, and my professor will, indeed care.
But the first range is "1-10" and the second is "11-20"... so it causes this problem:

1-10 |
11-20 |
21-30 |
...
91-100 |

If I could have 002, 003...010, 091, etc, it would fix this, wouldn't it?
I have no idea how to achieve this, though.
Help greatly appreciated.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use System.out.printf(String format, Object parameter)

The format string something like this "%03", will help, to print integer in the format "001", 039", etc..

To know more about from where I derived the format string, look here.

HTH and Welcome to JavaRanch !!

 
Campbell Ritchie
Sheriff
Posts: 53769
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This Java Tutorials section may be easier to understand.
 
Ryan Akim
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, I will try it.
 
Campbell Ritchie
Sheriff
Posts: 53769
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!