Parameter Variables

  1. Parameter variables are variables defined in the parameter list of a method:

    Example:
          public class Dictionary
          {
    	 ...
    	 public void enterWord(String w, String def)
    	 {
    	    int i;
    	    String x;
    
    	    ....
    	 }
          }
    
          public class myProgram
          {
    	 public static void main(String argv[])
    	 {
    	    Dictionary d;
    	    int i, j, k;
    	    String s;
    
    	    ...
    	 }
          }
    
    

  2. Purpose of Parameter Variables:

    Schematically:

    A concrete example:

  3. Lifetime of a parameter variable:

  4. Scope of a parameter variable:

  5. Conclusion:

  6. Difference between Parameter variables and local variables that are defined at the beginning of the method:

    DEMO: click here