Java Reference
In-Depth Information
Static variables are persistent variables attached to the class. These static
variables are stored in the global memory and can be accessed at any time from
any function. Thus static variables prove very useful for sharing information
between different blocks of instructions encapsulated into functions.
3.4 Pass-by-value of function arguments
3.4.1 Basic argument passing mechanism
Whenever calling a function in Java, the arguments (which are potentially
arbitrarily complex expressions that may also include other function calls)
are evaluated sequentially. Java compiler javac then performs the necessary
implicit casting operations, if necessary, of these evaluated expressions, and
complain with error messages in case the types of evaluated expressions do not
match the definition types of function arguments. Thus a generic function call
prototyping syntax is as follows:
F(ExprArg1, ..., ExprArgN)
Even if the function F is called with plain variables as is usually the case (say,
function call F(var1, ..., varN) ), these variables are in fact basic expressions
that are evaluated in this case to their stored values. Once the body of the
function is entered, there is no longer direct access to these variables. Executing
the function call thus amounts to executing this function where argument
variables and evaluated expressions have been binded :
static TypeF F()
{
Type1 arg1=ExprArg1;
...
TypeN argN=ExprArgN;
// Body of the function
...
}
3.4.2 Local memory and function call stack
In Java, variables declared in instruction blocks are all created and stored in
the local memory of the corresponding function. This local memory is named
the function call stack. Whenever a function is called, the required memory for
the local variables is allocated into the function stack , and the arguments are
passed by value as illustrated in Figure 3.1. Whenever inside the body of the
 
Search WWH ::




Custom Search