• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

BJO - is that any different between argument and parameter ?

 
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, sometime confuse on the term meaning ...is argument means parameter ? thank you
 
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Argument and parameter are different. A parameter consists of a type and a variable name, and it is declared in a method signature to signify that the method expects an argument matching that parameter.

An argument is a value passed to a method.

For example:


The parameter is named p and is of type int. The printOneBigger method expects an argument of that type to be passed to it from some other code. Here is some code that invokes the printOneBigger method using an argument of 6:

 
author
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Couldn't have done better myself! To put it simply:

A parameter is a variable; an argument is a value that we pass in to a parameter.

That being said, folks often use the term "argument" in casual conversation for both: e.g., for the following method:

public void print(String filename) { ... }

it is not uncommon for folks to say "The print method declares one argument, filename, of type String," which is, technically speaking, incorrect; the proper phraseology would be "The print method declares one parameter, filename, of type String" or "The print method takes one argument of type String."

Regards,

Jacquie
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic