Array and Method
Find the minimum value in an array
Find the minimum value in two arrays
The Java Method The Java method receives the array as a parameter
Passing an Value as Parameter (1)
Pass-by-value Mechanism The Java programming language uses only the pass-by- value mechanism. For the calling method: The calling method copies the value of the actual parameter into the formal parameter For the called method: The called method obtains the information directly from the parameter variables
Passing an Value as Parameter (1)
Passing an Value as Parameter (2)
Passing an Value as Parameter (3)
Passing an Value as Parameter (4)
Passing an Value as Parameter (5)
Passing an Value as Parameter (6)
Passing an Value as Parameter (7)
Passing an Value as Parameter (8)
Passing an Value as Parameter (9)
Passing an Value as Parameter (10)
Example Codes
Passing an Array as Parameter (1)
Passing an Array as Parameter (2)
Passing an Array as Parameter (3)
Returning an array as return value in a method (1) assignment statement: variableName = callSomeMethod( parame1, param2, ... ); Return value of a method: the replacement value of a method invocation
Returning an array as return value in a method (2)
Java program that returns an array (3)
Java program that returns an array (4) The variable x is of the type double[ ] which means it contains the reference (location/address) of a double typed array Therefore, the statement return(x) will return the reference (location/address) of a double typed array
Java program that returns an array (5)