0
public static void main(String args[])
problem statement : public static void main(String args[]) Query:why we can't change this String type to int or any other datatype.
1 Réponse
+ 4
Gurmeet Singh
main method accepts only String array because when you pass command line arguments then we pass values with space which is finally convert to String array so main method accepts string array.
This string array may contain integer value, double value or string value.
So suppose you have passed 10 AJ
So we will read this value like this:
String num = args[0];
String name = args[1];
You can convert args[0] means num to integer using parseInt method
So int num1 = Integer.parseInt(num);