Results 1 to 4 of 4
- 10-05-2012, 12:18 AM #1
Member
- Join Date
- Apr 2012
- Posts
- 25
- Rep Power
- 0
Execute main args.length number of times
I want the number of times main's code is executed to be dependent on the number of comman-line arguments passed to the program. The least troublesome way I can think of is to wrap all of the code in a big for loop..
But is there a better way to do it?
Thanks in advanceLast edited by cherrychives; 10-05-2012 at 01:00 AM.
- 10-05-2012, 01:05 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
Re: Execute main args.length number of times
If main() works on one command line argument at a time you could move its code to a different method. Then main() would just call this other method within a loop.
- 10-05-2012, 01:19 AM #3
Member
- Join Date
- Apr 2012
- Posts
- 25
- Rep Power
- 0
Re: Execute main args.length number of times
Thank you pbrock.
In my particular program, the minimum length of args is 3, and the first two arguments are used every time the code is executed, so it would it still be more efficient to invoke a separate method and pass 3 parameters each time?
- 10-05-2012, 06:03 AM #4
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
Similar Threads
-
Calling args from main method
By bogojevicka in forum New To JavaReplies: 3Last Post: 01-16-2012, 09:34 PM -
Dice help. posting the number of times a number is rolled.
By cookiejarvus in forum New To JavaReplies: 13Last Post: 12-04-2011, 11:08 PM -
Printing the Number of Times a Number in a Range Shows up
By space4rent00 in forum New To JavaReplies: 1Last Post: 02-05-2010, 10:42 PM -
Why can't we write main without String args[]
By shailender in forum New To JavaReplies: 4Last Post: 11-05-2008, 10:58 AM -
presse 1 menuitem execute 4 times the same JFrame
By marcvb in forum New To JavaReplies: 0Last Post: 12-27-2007, 09:48 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks