Here you can find the source of median(List
public static double median(List<Double> list)
//package com.java2s; //License from project: Open Source License import java.util.Collections; import java.util.List; public class Main { public static double median(List<Double> list) { Collections.sort(list);/*from w w w. ja va 2s .c o m*/ int i = list.size() / 2; if (list.size() % 2 == 1) return list.get(i); return (list.get(i) + list.get(i + 1)) / 2; } }