subject

Write the removeEvens() method, which receives an array of integers as a parameter and returns a new array of integers containing only the odd numbers from the original array. The main program outputs values of the returned array. Hint: If the original array has even numbers, then the new array will be smaller in length than the original array and should have no blank element.
Ex: If the array passed to the removeEvens() method is [1, 2, 3, 4, 5, 6, 7, 8, 9], then the method returns and the program output is:
[1, 3, 5, 7, 9]
Ex: If the array passed to the removeEvens() method is [1, 9, 3], then the method returns and the program output is:
[1, 9, 3]
LAB: Remove all even numbers from an array
LabProgram. java L.
1 import java. util. Arrays;
2
3 public class LabProgram {
4
5 public static int[] removeEvens(int [] nums) {
6
7
8 }
9
10 public static void main(String[] args) {
11
12 int [] input {1,2,3,4,5,6,7,8,9};
13 int [] result = removeEvens(input);
14
15 // Helper method Arrays. toString() converts int[] to a String
16 System. out. println(Arrays. toString(result)); // Should print [1, 3, 5, 7, 9]
17 }
18 }

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 13:00
Why the bear has a slunky tail determine the meaning of the word slunk in the story
Answers: 1
question
Computers and Technology, 25.06.2019 05:00
The ratio of men to women in a certain factory is 3 to 4 .there are 210 men.how many workers are there?
Answers: 2
question
Computers and Technology, 25.06.2019 05:10
What is the output of the following program? #include using namespace std; class bclass { public: void print() const; bclass(int a = 0, int b = 0); //postcondition: x = a; y = b; private: int x; int y; }; class dclass: public bclass { public: void print() const; dclass(int a = 0, int b = 0, int c = 0); //postcondition: x = a; y = b; z = c; private: int z; }; int main() { bclass bobject(2, 3); dclass dobject(3, 5, 8); bobject.print(); cout < < endl; dobject.print(); cout < < endl; return 0 ; } void bclass: : print() const { cout < < x < < " " < < y < < endl; } bclass: : bclass(int a, int b) { x = a; y = b; } void dclass: : print() const { bclass: print(); cout < < " " < < z < < endl; } dclass: : dclass(int a, int b, int c) : bclass(a, b) { z = c; }
Answers: 3
question
Computers and Technology, 25.06.2019 06:30
Which component is typically used as an amplifier a battery a transistor a microchip a diode
Answers: 1
You know the right answer?
Write the removeEvens() method, which receives an array of integers as a parameter and returns a new...
Questions
question
Mathematics, 18.10.2020 09:01
question
History, 18.10.2020 09:01
question
Biology, 18.10.2020 09:01
question
History, 18.10.2020 09:01
question
Mathematics, 18.10.2020 09:01