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, 23.06.2019 07:30
To check spelling errors in a document, the word application uses the to determine appropriate spelling. internet built-in dictionary user-defined words other text in the document
Answers: 2
question
Computers and Technology, 23.06.2019 13:30
Spoons are designed to be used for: spring hammering. applying body filler. identifying high and low spots. sanding highly formed areas.
Answers: 3
question
Computers and Technology, 24.06.2019 07:00
Why do we mark tlc plates with pencil and not with pen
Answers: 2
question
Computers and Technology, 24.06.2019 09:30
Retype the statements, correcting the syntax errors. system.out.println("num: " + songnum); system.out.println(int songnum); system.out.println(songnum " songs"); note: these activities may test code with different test values. this activity will perform two tests: the first with songnum = 5, the second with songnum = 9. see how to use zybooks.
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
Physics, 22.08.2020 07:01
question
Mathematics, 22.08.2020 07:01
Questions on the website: 13722363