Here you can find the source of getMedianValue(ArrayList
public static double getMedianValue(ArrayList<Double> values)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Collections; public class Main { public static double getMedianValue(ArrayList<Double> values) { if (values.isEmpty()) { return -1.0; }// w w w. j a v a 2s . c om Collections.sort(values); if (values.size() % 2 == 1) { return values.get(values.size() / 2 + 1); } double lower = values.get(values.size() / 2 - 1); double upper = values.get(values.size() / 2); return (lower + upper) / 2.0; } }