The header for the main
method is
public static void main (String[] args)
Could you technically replace "args" with anything you want? Also, why is the parameter an array?
The header for the main
method is
public static void main (String[] args)
Could you technically replace "args" with anything you want? Also, why is the parameter an array?
args
is just a name for the argument in a method. You can rename it to whatever you want. The JVM doesn't need to know what the argument is named; only the type, String[]
, is important.
dont break the start point of the app
static void main(String[] whateverYouNeed)
You can rename it to any proper Java identifier. The application needs to be able to accept multiple command-line arguments. It doesn't necessarily have to be an array, you can use varargs
also.
static void main(String... whateverYouNeed)
The main method could be written as:
The parameter name args could be replaced with any valid Java identifier like blah, programArgs, and so on. It's an array to accept any number of command line arguments. For example: