Information Technology Reference
In-Depth Information
Actual Parameters
When your code calls a method, the values of the formal parameters must be initialized before
the code in the method begins execution.
￿
The expressions or variables used to initialize the formal parameters are called the
actual parameters .
￿
The actual parameters are placed in the parameter list of the method invocation.
For example, the following code shows the invocation of method PrintSum that has two
actual parameters of data type int .
PrintSum( 5, SomeInt );
Expression Variable of type int
When the method is called, the value of each actual parameter is used to initialize the cor-
responding formal parameter. The method body is then executed. Figure 5-6 illustrates the
relationship between the actual parameters and the formal parameters.
Figure 5-6. Actual parameters initialize the corresponding formal parameters.
When you call a method, the following must be true:
￿
The number of actual parameters must be the same as the number of formal parameters
(with one exception, which I will discuss later).
￿
Each actual parameter must match the type of the corresponding formal parameter.
Search WWH ::




Custom Search