Computers and Technology

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 }

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 05:20, reeeeeee32
What did creator markus β€œnotch" persson initially call his game
Answers: 1
image
Computers and Technology, 23.06.2019 23:30, ayjahj
What can you prevent issues related to downloading content form the internet
Answers: 1
image
Computers and Technology, 24.06.2019 02:30, Esmail
Write the pseudo code for this problem based on what you learned from the video. the purpose is to design a modular program that asks the user to enter a distance in kilometers, and then converts that distance to miles. the conversion formula is as follows: miles = kilometers x 0.6214
Answers: 3
image
Computers and Technology, 24.06.2019 11:20, tiffanibell71
Colby works as a shipping clerk for a major package delivery service. some of his daily tasks include tracking shipments and entering orders. which aspect of the information technology cluster would he most likely be trained in? a. networkingb. databasesc. hardwared. software
Answers: 2
Do you know the correct answer?
Write the removeEvens() method, which receives an array of integers as a parameter and returns a new...

Questions in other subjects:

Konu
World Languages, 05.12.2021 17:10
Konu
Social Studies, 05.12.2021 17:10