+ 1
Why does main function in java accepts only string array as arguments ?
static void main (string [] args) why only string ?
3 Réponses
+ 3
Because it stores the command line arguments which could be anything. It's best to accept them as an array of strings (there can be many) and later decide to cast them accordingly.
+ 2
because strings can contain any type of value
0
The main function can contain any type of parameters but in the case if we do not know what type of input would be given by the user, it is best to accept all the inputs as an array of strings and then convert the input data into the required data type by using the abstract String class