main() method take a String array argument?
One of hundreds of answers available with our premium content service.
A: The static main() method takes a String array as an argument to provide a best match with the way that command line arguments are fed into a Java program. A Java program may be started with no command line arguments, in which case the String array is zero length, or it may have one or more arguments. The Java runtime system passes an array that matches the number of command line arguments that are given, so there is a direct correspondence between the program input and the data received by the main method.
Each storage slot in the String array passed to the main() method contains the String value of the relevant command line argument, indexed from zero. The example program below repeats the command line arguments in the order they are given.
… full answer hidden
Premium members click below for full answer
Why does the main() method take a String array argument?