Why only String[] args in java instead of Object[] args?
command-line-arguments, command-prompt, java
Solution
Java is designed with portability in mind, so that Java programs would be invoked by diverse operating environments. Having the environments pass Java objects to `main` would put too much restrictions on the caller system, because that system would have a task of "understanding" the input and converting it to Java objects.
Strings, on the other hand, are universal: all operating environments have them. Therefore, Java specification required strings, knowing that your Java program would be able to process and understand them better than an external environment.
Problem
In java, as per the Java Language Specification 12.1.4 the main method should be declared as follows: ``` public static void main(String[] args){ //code of program } ``` With the use of `String[] args` we can get command-line arguments. Sometime those command-line arguments needs to be converted to appropriate type. suppose if you have supplied any number `123` as an argument and you want to convert it to `int` then we can use one of the following conversion methods: ``` int n1=Integer.valueOf(args[0]); //or int n2=Integer.parseInt(args[0]); ``` But, if java could have provided use of `Objects[] args` instead `String[] args` then we can easily convert from one type to another, for this example conversion would take place as follows: ``` public static void main(Object[] args){ int n1=(Integer)args[0]; } ``` I'm not getting this why java have used `String[] args` and not `Object[] args`?