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?