public static int] filterodd(int] list) This method will take an array of ints as input. It will then create a new array
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
public static int] filterodd(int] list) This method will take an array of ints as input. It will then create a new array
public static int] filterodd(int] list) This method will take an array of ints as input. It will then create a new array that has all the odd numbers removed. The order of the remaining numbers should not change. For example: int [] in ={1,2,7,2,5,6,3}; int [] out = filterodd(in); System. out. println(Arrays.toString(out)) will output [2,2,6]. Remember that an array is an object. Trying to print it directly will output its memory address. Instead, we can make use of the Arrays class and its static toString () method. Note: the length of the output array should only be as big as needed. In the main () method write three test cases to verify that your method is correct. (One is already done for you.) Along with the output you should use the array's length attribute to show that no extra space is used.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!