Replies To: Args or arguments, is it any difference?

Re: Args or arguments, is it any difference?

Posted 17 October 2013 - 01:21 PM

POPULAR

You can call it args, arguments.. or potatoes. It is the name given to the String array that contains the command-line arguments that main() is automatically supplied with. Call it args though: there is no reason to break with an accepted practice.

Re: Args or arguments, is it any difference?

Posted 17 October 2013 - 01:31 PM

Remember that the main method is really no different to any other method in base thinking. As long as the method signature is public static void main(String[]) (which it is regardless of what you name the variable) the compiler won't care at all.

Defining main is no different to defining any other method. The only special thing about main is it becomes the method that the compiler looks at to define the entry point for your program. It's just like any other method where you can name you parameters anything you want (although remember that variable names should be as descriptive as possible).

Re: Args or arguments, is it any difference?

Posted 18 October 2013 - 01:13 PM

andrewsw, on 17 October 2013 - 09:21 PM, said:

You can call it args, arguments.. or potatoes. It is the name given to the String array that contains the command-line arguments that main() is automatically supplied with. Call it args though: there is no reason to break with an accepted practice.

Ah, thank you. Now I understand it a bit better. Some books I have read on my native tongue started to change it back and forth and I did not understand why. Now I understand and one question mark is away. Big thank you!

modi123_1, on 17 October 2013 - 09:22 PM, said:

If I remember right - they are just command line arguments.. so you can name that variable what every ou like.

Re: Args or arguments, is it any difference?

Posted 18 October 2013 - 01:24 PM

Ryano121, on 17 October 2013 - 09:31 PM, said:

Remember that the main method is really no different to any other method in base thinking. As long as the method signature is public static void main(String[]) (which it is regardless of what you name the variable) the compiler won't care at all.

Defining main is no different to defining any other method. The only special thing about main is it becomes the method that the compiler looks at to define the entry point for your program. It's just like any other method where you can name you parameters anything you want (although remember that variable names should be as descriptive as possible).

Thank you. Yes, now I have tried with different variation after the ...String[].... Here is an simple example

Re: Args or arguments, is it any difference?

Posted 18 October 2013 - 04:21 PM

andrewsw, on 17 October 2013 - 09:21 PM, said:

You can call it args, arguments.. or potatoes. It is the name given to the String array that contains the command-line arguments that main() is automatically supplied with. Call it args though: there is no reason to break with an accepted practice.

I'm going to write all my main methods with (String[] potatoes) now because potatoes

Re: Args or arguments, is it any difference?

Posted 18 October 2013 - 05:38 PM

Ryano121, on 17 October 2013 - 03:31 PM, said:

Defining main is no different to defining any other method. The only special thing about main is it becomes the method that the compiler looks at to define the entry point for your program. It's just like any other method where you can name you parameters anything you want (although remember that variable names should be as descriptive as possible).

As long as we're being fussy, I should point out that it's not the compiler that finds main as the entry point - it's the jvm. The compiler is out of the picture when it comes to run time. Pedantic, I know...

Re: Args or arguments, is it any difference?

Posted 19 October 2013 - 08:33 AM

Quote

As long as we're being fussy, I should point out that it's not the compiler that finds main as the entry point - it's the jvm. The compiler is out of the picture when it comes to run time. Pedantic, I know...

Well the compiler still has to find the main method signature, as if it didn't you would never get the compile time error of no entry point defined.

Besides I thought the compiler marked main in the created bytecode to aid the jvm when trying to run it (at least this is what happens in .Net). In a sense don't they both do the 'finding'?