I am learning Java, theres one thing I do not understand..
in the main routine:
public static void main(String[] args) {
I think I pretty much understand this, in the language I know, I think it would be like this:
public static function main(args:String):void {
The first thing I do not understand is what are the 2 brackets [] for in String[]? Also the second thing I am wondering, is if this is the first function that will be called (and called by something outside the program), will there ever actually be a parameter passed?
Thanks.
The arguments to main are the options you pass into Java from the command line, passed in as an array. So for example :
java MyProgram foo bar zoo
takes three arguments, namely, foo, bar, and zoo
foo is args[0], bar is args[1], and zoo is args[2].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With