Here you can find the source of median(double... a)
public static double median(double... a)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010 BSI Business Systems Integration AG. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:// w ww .ja v a 2 s. com * BSI Business Systems Integration AG - initial API and implementation ******************************************************************************/ import java.util.Arrays; public class Main { public static double median(double... a) { if (a == null) { return 0; } int count = a.length; double[] b = new double[a.length]; System.arraycopy(a, 0, b, 0, count); Arrays.sort(b); if (count > 0) { return b[count / 2]; } else { return 0; } } }