0
Why we use string []args
2 Answers
+ 5
https://www.sololearn.com/discuss/1187633/?ref=app
https://www.sololearn.com/discuss/1520755/?ref=app
https://www.sololearn.com/discuss/1097654/?ref=app
https://www.sololearn.com/discuss/125799/?ref=app
https://www.sololearn.com/discuss/376898/?ref=app
https://www.sololearn.com/discuss/347596/?ref=app
https://www.sololearn.com/discuss/1586483/?ref=app
https://www.sololearn.com/discuss/668647/?ref=app
https://www.sololearn.com/discuss/1691991/?ref=app
https://www.sololearn.com/discuss/1048215/?ref=app
https://www.sololearn.com/discuss/251960/?ref=app
https://www.sololearn.com/discuss/256287/?ref=app
https://www.sololearn.com/discuss/232382/?ref=app
https://www.sololearn.com/discuss/1363371/?ref=app
https://www.sololearn.com/discuss/464184/?ref=app
0
In the main method ?
Well as it's name suggest, the main method is a method and thus can take arguments like any other methods.
Suppose your program's name is A. If another program (let's call it B) wants to start your program A. He can do so by calling the main method from A.
Then, maybe B has information to give to A to allow it to run properly. That is done through the args arguments from the main method, under the form of an array of String
Most of the time though, you may ignore these arguments as they won't be of any use, as your program won't have to interact with other programs and don't require arguments to launch it (from a command line for example, but that more advanced already)