# Write a class ReorderArray with a public method reorder that takes one parameter arr of type int[] and returns the arr such that all even numbers in the array come to the front of the arr

Write a class ReorderArray with a public method reorder that takes one parameter arr of type int[] and returns the arr such that all even numbers in the array come to the front of the arr.

Assumptions:

1. arr is never null

Here is an example:

```Enter no of elements in the array:
6
Enter elements in the array seperated by space:
3 5 6 4 2 4
6
4
2
4
3
5```

### Solution:

``````package q11090;

public class ReorderArray {
/** *Arrange all even numbers to infront of the array
*
*
*
*
@return result */
public int[] reorder(int[] arr) {
int size = arr.length;
int temp=0,count=0;
for(int i = 0; i < size; i++){
if(arr[i]%2==0){
for(int j=i; j > count; j--){
temp = arr[j-1];
arr[j-1] = arr[j];
arr[j] = temp;

} count++;

}

}
return arr;

}

}``````

Candidates having any kind of query so he/she can ask in our comment section. Our Panel will b reverting back as soon as possible. Thank You. For more details visit our website (https://speedjobalert.com/)