how to receive array from function in java code example
Example 1: how do you make a method that returns an array java
public static int[] numbers()
{
int[] arr={5,6,7,8,9}; //initializing array
return arr;
}
Example 2: passing array to function java
public int min(int [] array) {
int min = array[0];
for(int i = 0; i<array.length; i++ ) {
if(array[i]<min) {
min = array[i];
}
}
return min;
}
int minimum = min(myArray)