WHAT IS THE DIFFERENCE BETWEEN ARGUMENTS AND PARAMETERS ?

arguments
The things you specify between the parentheses when you're invoking a method:
doStuff("a",2); // invoking doStuff, so a & 2 are arguments

parameters
The things in the method's signature that indicate what the method must receive when it's invoked
void doStuff(String s, int a) { } // we're expecting two
// parameters: String and int

2 comments:

  1. Did u mean arguments means values and parameter means datatype of those values?

    please correct me if i am wrong ?

    ReplyDelete
  2. No Laxman,
    Argument is the value or variable that you are passing along with the method while invoking the method. i.e add(23,24). Here 23 and 24 are the arguments
    and
    Parameters are the elements those you are enclosing while declaring or defining the method . i.e
    public int add(int arg0,int arg1){
    //method body goes here.
    }
    Here arg0 and arg1 are parameters to method add.

    ReplyDelete