Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java median of list

public static double Median(ArrayList<Double> values) {
    Collections.sort(values);

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

        return (lower + upper) / 2.0;
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java bean 
Java :: java for each loop 
Java :: java arraylist deepcopy 
Java :: isnull java 
Java :: timestamp with zone java 
Java :: start activity for result deprecate 
Java :: arraylist to int array conversion in java 
Java :: android application subclass 
Java :: How to build a Sudoku solver, in Java? 
Java :: redondear a 2 decimales java 
Java :: load a list from text file java 
Java :: how to right align in java 
Java :: formatting an integer in java 
Java :: find minimum in array java 
Java :: get string of radio button in android 
Java :: java integer division tofloat 
Java :: replace character in string java 
Java :: how to check if notification is showing in android 
Java :: arraylist input from user java 
Java :: java print formatted string 
Java :: Maven Dependency for flyway 
Java :: has been compiled by a more recent version of the Java Runtime (class file version ), this version of the Java Runtime only recognizes class file versions up to 
Java :: get element in arraylist java 
Java :: how to use arrays java 
Java :: delete one item from list recycleview 
Java :: how to update java runtime 
Java :: java program to remove duplicate words in a string 
Java :: linear search algorithm java 
Java :: converting char array to string 
Java :: spring boot get request body 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =