*
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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "difference between parameter and arguments" Watch "difference between parameter and arguments" New topic
Author

difference between parameter and arguments

Muhammad Usman
Greenhorn

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
Sheriff

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:
someObject.aMethod("hello",1);
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.
HIH
------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[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
Greenhorn

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.
anyObjest.anyMethod(1,5.5)
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: http://aspose.com/file-tools
 
subject: difference between parameter and arguments