Calculate+median+of+arraylist

3-4-13 added the ability to calculate the median of an arraylist to my UsefulTools class without use of Expression class class

code here

public static double Median(ArrayList values) { //first make sure we are dealing with a list of doubles if(!values.get(0).getClass.equals("class java.lang.Double")) { values = convertArrayListOfStringsToDoubles(values);

}

Collections.sort(values); System.out.println(values); if (values.size % 2 == 1) return Double.valueOf(String.valueOf(values.get((values.size+1)/2-1)).toString).doubleValue; else { double lower = Double.valueOf(String.valueOf(values.get(values.size/2-1)).toString).doubleValue; double upper = Double.valueOf(String.valueOf(values.get(values.size/2)).toString).doubleValue;

return (lower + upper) / 2.0; } }

public static ArrayList convertArrayListOfStringsToDoubles(ArrayList values) { for(int i=0; ipublic static double Median(ArrayList values)  {  Collections.sort(values);

 if (values.size % 2 == 1)  return Double.valueOf(String.valueOf(values.get((values.size+1)/2-1)).toString).doubleValue;  else  {  double lower = Double.valueOf(String.valueOf(values.get(values.size/2-1)).toString).doubleValue;  double upper = Double.valueOf(String.valueOf(values.get(values.size/2)).toString).doubleValue;

 return (lower + upper) / 2.0;  }  }