Q:

Re-arranging array

I have an assignment they ask me to re-arrange an array from the even numbers to the odd numbers 
like this:
    Sample Output:
    Please enter array of 5 integers: 
    1 2 5 6 4
    the array after re-arranging:
    2 6 4 1 5

I couldn't do it " I cant use methods" can anyone help me ?
this is my code:
 public static void evenOdd(int[] arr){
     int i=0;
     int arr1[] = new int[5];
     for (i=0;i<5;i++)
     { 
         if (arr[i]%2==0)
             arr1[i]=arr[i];
     }
     for (i=0;i<5;i++){
          if(arr[i]%2!=0)
              arr1[i]=arr[i];
     }//end for
     for(i=0;i<5;i++)
     System.out.print(arr1[i]+" ");
     System.out.println("");
}//end method 

THANK YOU

A:

The problem is when you add them into the new array you are putting them in the same position: i.  Use a separate int to keep count of what part of the index you are on.
public static void evenOdd(int[] arr){
    int i=0;
    int count = 0;
    int arr1[] = new int[5];
    for (i=0;i<5;i++) { 
        if (arr[i]%2==0) {
            arr1[count]=arr[i];
            count++;
        }
    }
    for (i=0;i<5;i++){
        if(arr[i]%2!=0) {
            arr1[count]=arr[i];
            count++;
        }
    }//end for
    for(i=0; i < 5; i++) {
        System.out.print(arr1[i]+"\n");
    }
}//end method 

