Write a method that accepts an array of integers as a parameter and returns a reference to an array that contains the even numbers in the array original array. The returned array should have a size equal to the number of even numbers in the original array.
What will be an ideal response?
```
public int[] getEvenArray(int[] numbers) {
int size = 0;
for(int i = 0; i < numbers.length; i++)
if(numbers[i]%2 == 0)
size++;
int[] evenArray = new int[size];
int evenArrayIndex = 0;
for(int i = 0; i < numbers.length; i++) {
if(numbers[i]%2 == 0) {
evenArray[evenArrayIndex] = numbers[i];
evenArrayIndex++;
}//end if
}//end for
}
```
You might also like to view...
To apply the MIN or MAX function to a selected range of cells, you begin by clicking the _______ arrow
Fill in the blank(s) with correct word
What is the significance of understanding the figure/ground relationship?
What will be an ideal response?
Which of the following statements is true?
What will be an ideal response?
Once you complete the planning phase, you need to set up the structure of the site by creating a wireframe.
Answer the following statement true (T) or false (F)