Download presentation
Presentation is loading. Please wait.
1
Array and Method
2
Find the minimum value in an array
3
Find the minimum value in two arrays
4
The Java Method The Java method receives the array as a parameter
5
Passing an Value as Parameter (1)
6
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
7
Passing an Value as Parameter (1)
8
Passing an Value as Parameter (2)
9
Passing an Value as Parameter (3)
10
Passing an Value as Parameter (4)
11
Passing an Value as Parameter (5)
12
Passing an Value as Parameter (6)
13
Passing an Value as Parameter (7)
14
Passing an Value as Parameter (8)
15
Passing an Value as Parameter (9)
16
Passing an Value as Parameter (10)
17
Example Codes
18
Passing an Array as Parameter (1)
19
Passing an Array as Parameter (2)
20
Passing an Array as Parameter (3)
21
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
22
Returning an array as return value in a method (2)
23
Java program that returns an array (3)
24
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
25
Java program that returns an array (5)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.