Here you can find the source of getMedian(List
public static double getMedian(List<Double> results)
//package com.java2s; //License from project: Open Source License import java.util.Collections; import java.util.List; public class Main { public static double getMedian(List<Double> results) { Collections.sort(results); if (results.size() % 2 == 0) return ((double) results.get(results.size() / 2) + (double) results.get(results.size() / 2 - 1)) / 2; else/*from w ww. ja v a 2s . co m*/ return (double) results.get(results.size() / 2); } }