Asked in Java Programming
What is a parameter variable in java?
May 14, 2012 3:37AM
A variable that is used as a parameter. If, for example, a method "methodA" calls a method "methodB", it may be desirable to pass information from methodA to methodB. This is done via parameters. In the calling program ("methodA"), and assuming you want to pass two integers, you might write something like:
//or with variables: methodB(a, b);
In methodB, the variables must be received:
methodB(int x, int y)
In this example, the number 5 (or the contents of variable "a") is copied to variable x, and can be used within the method body. Similarly, the second value (7, or b) is copied to variable "y", and can be used within methodB.