Here you can find the source of medianIndexInSorted(double[] arr)
public static int medianIndexInSorted(double[] arr)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static int medianIndexInSorted(double[] arr) { // TODO: Better tie breaking? Arrays.sort(arr);//from w w w. j a v a2s.c o m if (arr.length < 2) { return 0; } else if (arr.length % 2 == 0) { // return the higher of the 2 midpoints return (arr.length / 2); } else { // return exactly the midpoint return ((arr.length - 1) / 2); } } }