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).
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
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.
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.
subject: difference between parameter and arguments