New to the world of Java and I was wondering how to make a program that when run takes input in this form:
java ProgramName 1 2 3 4 5
That is, it takes 1,2,3,4 and 5 as inputs for the program. I’m guessing that it will take this as a string and that somehow I will need to convert this string to individual numbers?
The parameter
argsinmainis an array that contains the command-line arguments as strings. The following code will loop through the arguments and print them.For more information, have look at the documentation.