Professional Documents
Culture Documents
Fundamentals of Programming - Lab 6
Fundamentals of Programming - Lab 6
Fundamentals of Programming - Lab 6
CALLING OF FUNCTIONS
ARRAY
Array – stores multiple values in a single variable, instead of multiple
variables for each value
DECLARING ARRAYS
To declare or create arrays, use;
Long method
datatype[] 'array name'= new datatype['number of
values'];
'array name[0] = value;
'array name[1] = value;
'array name[2] = value;
Short method
Datatype 'array name' = {'values'};
Short method
int[] b = {10,20,30};
Output:
ARRAY FUNCTIONS
to.String() method
This displays all of the array values without needing to specify the array
indexes.
Example:
int[] n = {10, 20, 30, 40, 50};
System.out.println("The arrays are: " +
Arrays.toString(n));
Example:
For (a = 0; a < n.length; a++){
System.out.print(n[a]);
}
2D ARRAY FUNCTION/S
.deepToString method
Output:
int[] n = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100};