File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes difference between parameter and arguments Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "difference between parameter and arguments" Watch "difference between parameter and arguments" New topic

difference between parameter and arguments

Muhammad Usman

Joined: Nov 18, 2001
Posts: 29
i am having difficulty in understanding what is the difference between parameter and agruments.
also having difficulty to understand the reason for return type "void" in any method.
i hope u guys can help me

an student of Operation Badar ( a educational movement in Pakistan).
Valentin Crettaz
Gold Digger

Joined: Aug 26, 2001
Posts: 7610
Parameter are placeholders for values and/or object references in the signature of a method. Arguments are the actual values and/or object references you give when invoking a method.
For instance:
public void aMethod(String s,int i);
in the signature of aMethod, the first parameter is a reference to an object of type String and i is a primitive integer value.
You invoke aMethod (someObject is an instance of the class containing aMethod as member method) like this:
Here "hello" is the first String argument and 1 the second integer argument.
Concerning your second question, "void" is not a return type, it just indicates that nothing is returned by the method.
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform

[Blog] [Blogroll] [My Reviews] My Linked In
Colin Kenworthy
Ranch Hand

Joined: Aug 06, 2001
Posts: 88
The Java language says a method (but not constructors) has to define a return type in it's header when you code it. What do you do if your method does not return anything ? That is why the reserved word "void" is used - to say that this method does not return anything.
Sadaf Zaidi

Joined: Oct 09, 2001
Posts: 29
The variable use to store value is called Parameter and the valus pass in the method is called Argument.
publis static anyMethod(int a,double d)
In this method the int a and double d is a parameter.
Here we are calling anyMethod from anyObject and 1 and 5.5 are arguments (values) passing to a ad d.
I agree. Here's the link:
subject: difference between parameter and arguments
It's not a secret anymore!