0

Why always main function receives array of Strings as input parameters?

7th Feb 2017, 6:38 AM
Ashish Wayne
Ashish Wayne - avatar
3 odpowiedzi
0
These are the Strings you give as parameters calling the program e.g. via command line. For Example: myprogram -option1 -option2 -option1 is the first array member and -option2 the second
7th Feb 2017, 6:44 AM
Benjamin
0
can it be like main(int bob) ?
7th Feb 2017, 6:45 AM
Ashish Wayne
Ashish Wayne - avatar
0
Command Line Arguments were given as Strings. I guess main(int i) will result in an exception. But you can easily convert the Strings to Integers using the Integer class. int i = Integer.parseInt(String xyz) But be careful to parse arguments without checking, otherwise you will get an exception.
7th Feb 2017, 7:00 AM
Benjamin