Error suggest to modify the programme to even number of array element

package com.codegym.task.task26.task2601;
import java.util.*;
/*
Read online about the median of a sample
*/
public class Solution {
public static void main(String[] args) {
}
public static Integer[] sort(Integer[] array) {
Integer[] copyArray = new Integer[array.length];
for(int i = 0 ; i<array.length ; i++)
copyArray[i] = array[i];
Arrays.sort(copyArray);
double median = 0;
if((array.length %2) != 0)
median = copyArray[(copyArray.length/2)];
else{
median = (copyArray[copyArray.length/2]+(double)copyArray[(copyArray.length/2)-1])/2;
}
final double meddian = median;
System.out.println("Median: "+meddian);
Comparator<Integer> compare = new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
long result = Math.round((Math.abs(o1-meddian)) - (Math.abs(o2-meddian)));
return (int)result;
}
};
Arrays.sort(array,compare);
return array;
}
}