Search code examples
javascjp

Arguments and Parameters


I am reading the SCJP 6 book by Sierra and Bates. In the first chapter there is a section on "Final Arguments" (page 41). In this section it refers to "method arguments" as "variable declarations that appear in between the parentheses in a method declaration".

However, elsewhere (in the book and on the net) the convention is that we "pass arguments" and "declare parameters".

Am I reading this wrong ?


Solution

  • You're right - the book is wrong in this specific place, and right elsewhere. Arguments appear at the call site, parameters are part of the method declaration.

    The Java language specification backs this up - method invocation expressions have argument lists (JLS 15.12); method declarations have formal parameters (JLS 8.4.1), which includes this:

    When the method or constructor is invoked (§15.12), the values of the actual argument expressions initialize newly created parameter variables, each of the declared type, before execution of the body of the method or constructor.

    If it's any consolation, the terms are used incorrectly all over the place on the net, even by those who know better but are very occasionally careless... and I include myself in that, even though I try hard on this one :( A good example of this is in C#, where version 4 introduced named arguments and optional parameters, but the feature is described with just about every incorrect permutation you could mention.