Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes Number generation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Number generation" Watch "Number generation" New topic
Author

Number generation

michael yue
Ranch Hand

Joined: Nov 20, 2003
Posts: 204
Hi all,

I dont know how to come up with the simplest algorithm for this problem.
I want to generate a range of numbers if the front of the numbers begin with 0.
Example start number is 001 and end number is 008
then it will generate 001,002,003 and so on till 008.

Also i am a bit stumped on preventing wrong input generation for example when first number input 001 but end number input 0005.
Thanks a lot. Hope i am clear enough.
Mark Patrick
Ranch Hand

Joined: Feb 22, 2004
Posts: 51
Look at the API specification for java.text.DecimalFormat.


Mark Patrick<br />SCJP 1.4
Mark Patrick
Ranch Hand

Joined: Feb 22, 2004
Posts: 51
This will do the trick:

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Number generation