Here you can find the source of getMedian(int[] array)
public static float getMedian(int[] array)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static float getMedian(int[] array) { // return median value if (array.length == 0) return 0; Arrays.sort(array);//from ww w . j a va 2s .com float median; if (array.length % 2 == 0) median = ((float) array[array.length / 2] + (float) array[array.length / 2 - 1]) / 2; else median = (float) array[array.length / 2]; return median; } }