Challenge: Remove Even Integers from an Array

Given an array of size n, remove all even integers from it. Implement this solution in Java and see if it runs without an error.


Here is a short guide to these challenge lessons.

  1. The method definition is always given in the problem statement with the expected arguments and method name to be used as is in the solution. If you change it, your code will not compile
  2. When you do get compile-time errors, they will sometimes refer to line numbers and code, which you did not write. That is fine; that is just our evaluation code. Although, rest assured that our code compiles. When in doubt, refer to the solution given and paste that in.
  3. Sometimes you are going to have to return from methods in a form that aligns with the test cases. Your solution may not be incorrect, but your form of returning might not be what the evaluation code expects. For example, you might return a number, but our test cases might expect an array. Watch out for that. Good luck! πŸ€

Problem Statement

In this problem, you have to implement the int [] removeEven(int[] arr) method, which removes all the even elements from the array and returns back updated array.

Method Prototype

int[] removeEven(int[] arr);


An array with integers.


An array with only odd integers.

Sample Input

arr = {1, 2, 4, 5, 10, 6, 3}

Sample Output

arr = {1, 5, 3}

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy