I'm trying to loop through a statement block x number of times, where the user inputs the integer x from the command line. However, the default command line argument is a string, so inputting "3" will cause the statement block to execute only once, as opposed to 3 times. Any ideas?
This is the construct I've been using. I want args.length to be equal to whatever integer I input from the command line.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Joined: Aug 01, 2011
Thanks for the reply. Unfortunately, I'm not quite sure how to do this. Can you show me how to do this in the context of equating integer input to args.length? Or perhaps direct me to a place to learn more about how I could do it? Thanks.
Everything passed in from the command line is done as a string. How would it know what to expect otherwise?
You then need to 'convert' the input into whatever you need. If you know the second param should be an int, then you convert it to and int (and probably save it in some new variable) and use it how you need to.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors