0
[DUPLICATE] Why is a String array with the name args used when calling the method in the following:
public static void main(String[ ] args) Tutorial doesn't explain the need for the array. I see that the method used is a String so I get that is needed. But why as an array? To store the information of the method? If it were int would it be int instead?
2 Answers
+ 3
It is used for command line arguments.
It's an array so you can pass any number of 'words/files/commands' that are already separated for you. If it was one long String you would need to split each command into an array anyway.
http://docs.oracle.com/javase/tutorial/essential/environment/cmdLineArgs.html
0
thank you!!!