This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Parameters and Arguments of a method. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Parameters and Arguments of a method." Watch "Parameters and Arguments of a method." New topic
Author

Parameters and Arguments of a method.

Sunali Anu
Greenhorn

Joined: Jun 04, 2007
Posts: 14
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

Joined: Jul 08, 2003
Posts: 24183
    
  34

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.


[Jess in Action][AskingGoodQuestions]
Bill Cruise
Ranch Hand

Joined: Jun 01, 2007
Posts: 148
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

Joined: Jan 29, 2003
Posts: 8791
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.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
Don't get me started about those stupid light bulbs.
 
subject: Parameters and Arguments of a method.