Here you can find the source of median(double[] l)
public static double median(double[] l)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; public class Main { public static double median(double[] l) { Arrays.sort(l);/* w w w. ja v a 2 s .co m*/ int middle = l.length / 2; if (l.length % 2 == 0) { double left = l[middle - 1]; double right = l[middle]; return (left + right) / 2; } else { return l[middle]; } } }