-2

i know method signature use parameter, and method use arguments when method call.

so i don't know why java main method parameter name 'args' is not 'param'

I am sorry that I am not good at English.

  • You are free to use any variable name as long as it is not a reserved word – Mohammad Feb 18 '21 at 06:37
  • yes i know that, but why Initial Name is args? – samsamsamsmasma Feb 18 '21 at 06:43
  • https://stackoverflow.com/questions/890966/what-is-string-args-parameter-in-main-method-java#:~:text=Those%20are%20for%20command%2Dline%20arguments%20in%20Java.&text=The%20reason%20for%20this%20is,piece%20of%20information%20it%20needs., you should better to read this posts – yusuf hayırsever Feb 18 '21 at 06:54
  • Does this answer your question? ["Parameter" vs "Argument"](https://stackoverflow.com/questions/1788923/parameter-vs-argument) – fantaghirocco Feb 18 '21 at 06:57
  • @samsamsamsmasma it isn't. it's just a convention they use in textbooks, it's short for arguments. But, feel free to call it fredAstaire in your code if you want. There is no "initial" or "fixed" name for that param – Stultuske Feb 18 '21 at 07:05
  • Convention made me understand. thank you! – samsamsamsmasma Feb 18 '21 at 07:07

3 Answers3

1

Just a variable name, you can use any name that meets the Java variable naming requirements

t0ta1o
  • 11
  • 1
  • 1
    thanks for your answer, but i want know Initial Developer is use args.not a param why? is there any other meaning? – samsamsamsmasma Feb 18 '21 at 06:47
  • You might as well ask why the main method is called 'main'. It could have been anything. – jr593 Feb 18 '21 at 07:49
  • I guess it is a historical issue. I have learned that params are used as keywords and system functions in some places. – t0ta1o Feb 19 '21 at 01:31
0

You can use any name for that, but "args" is short for "arguments". Some people prefer "parameter", some "argument". See also: "Parameter" vs "Argument"

Cornel Masson
  • 1,352
  • 2
  • 17
  • 33
0

It's not a matter of choice, it's about the meaning of the words: an argument is not a parameter

  • main(String args)
    args is the method argument

  • main(null)
    null is the parameter by which the method is invoked

See https://stackoverflow.com/a/1788926/1575188

fantaghirocco
  • 4,761
  • 6
  • 38
  • 48