Here you can find the source of calculateMedianOfArrayListInteger(List
public static Double calculateMedianOfArrayListInteger(List<Integer> integerList)
//package com.java2s; //License from project: LGPL import java.util.Collections; import java.util.List; public class Main { public static Double calculateMedianOfArrayListInteger(List<Integer> integerList) { if (integerList.size() > 1) { Collections.sort(integerList); double median; int middle = ((integerList.size()) / 2); if (integerList.size() % 2 == 0) { int medianA = integerList.get(middle); int medianB = integerList.get(middle - 1); median = Double.valueOf((medianA + medianB) / 2); } else { median = Double.valueOf(integerList.get(middle + 1)); }/*from w w w . jav a 2 s.c o m*/ return median; } else { return Double.NaN; } } }