Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
How would I calculate a median value in Java?
I have a class where I need to calculate the median value of a set of numbers, but I'm mainly not sure how to select the middle number for the median value?
2 Answers
- Anonymous1 decade agoFavorite Answer
If you don't want to use the standard method of dealing with an even number of values but would rather send back the two median values without averaging them, simply change the return type of the method to an ArrayList<Double> then pass back both of them within that array.
Read more: How to Calculate a Median in Java | eHow.com http://www.ehow.com/how_6513624_calculate-median-j...
Source(s): http://ji.gowebschool.com/ - ?Lv 61 decade ago
Sort the list first and then pick the middle value. If the list has an even number of elements average the two most center values together.