• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between Arguments and parameters

 
munish gupta
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the Difference between Arguments and parameters ...
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Those are two words that are often used for the same thing. There's no real difference.
 
Stephan van Hulst
Bartender
Pie
Posts: 5592
55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I always figured "parameter" refers to the local variable in the method signature. "Argument" refers to the value that's passed to this parameter.
Here 'x' is a parameter of foo(). '3' is an argument passed to foo().
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I too always had this same idea shown by Stephan...
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, in your example, the x in line 1 is the parameter, while the 3 in line 6 is the argument.
 
Stephan van Hulst
Bartender
Pie
Posts: 5592
55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yup.
 
dennis deems
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it useful to make such a distinction?
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it's just that you often find these terms in the literature. It's good to know precisely what each term means.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I too have the Opinion like Stephan and Roberto. but when I refer JLS, surprisingly it says it is argument .
http://java.sun.com/docs/books/jls/third_edition/html/classes.html#40942

For a method, an ordered 3-tuple consisting of:

argument types: a list of the types of the arguments to the method member.
return type: the return type of the method member and the
throws clause: exception types declared in the throws clause of the method member.

 
Stephan van Hulst
Bartender
Pie
Posts: 5592
55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The distinction is just as important as knowing the difference between "variable" and "value". It's an especially great help when you're studying generics, because the phrases "type parameter" and "type argument" are often used. Here "type parameter" will refer to a variable, often named T or E, which is able to hold a "type argument" or "type value" or simply a "type".
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seetharaman Venkatasamy wrote:I too have the Opinion like Stephan and Roberto. but when I refer JLS, surprisingly it says it is argument .
http://java.sun.com/docs/books/jls/third_edition/html/classes.html#40942

For a method, an ordered 3-tuple consisting of:

argument types: a list of the types of the arguments to the method member.
return type: the return type of the method member and the
throws clause: exception types declared in the throws clause of the method member.



As Jesper said in the first reply:
Those are two words that are often used for the same thing. There's no real difference.


And I will add: ...unless somebody chooses to make a distinction in some particular context.

If you look at the JLS's index under "argument", you'll see one or two entries, and "See also: parameter".

And in the text, you find stuff like this: "...then the anonymous constructor has one formal parameter for each actual argument..." (http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.9.5.1)

So it may not be entirely consistent in its usage. Although I do think the section you quoted could be referring the actual argument types. That is, the argument types list is telling us what the types of the actual arguments must be.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:The distinction is just as important as knowing the difference between "variable" and "value".


In other words, in many contexts it doesn't matter.

It's an especially great help when you're studying generics


Definitely.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you Stephan and Jeff
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic