• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parameters and Arguments of a method.

 
Sunali Anu
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to know the difference between the two. If some body could please help me with this.. Thanks.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

Most people use these two terms interchangeably, but there's a subtle difference in meaning. If you have a method like this:



then "x" is a parameter to the method. It's the variable listed in the declaration; whereas if you call the method like this



then "3" is an argument to the method call; it's the actual value passed in.
 
Bill Cruise
Ranch Hand
Posts: 148
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They're used interchangably in a lot of instances but here's the difference. When you define a method (or function), you give it a parameter. When you call the method you pass it an argument.



Here param is a parameter.



Here 5 is the argument being passed.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have sometimes seen Formal Parameter refer to the declaration, and Actual Parameter refer to the value passed.

http://chortle.ccsu.edu/CS151/Notes/chap34/ch34_3.html

There is just enough variety in usage to confuse us thoroughly. As long as a speaker or writer uses them consistently you can usually figger out what they mean sooner or later.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic