How to calculate the median of an array?

后端 未结 14 1744
北海茫月
北海茫月 2020-12-05 06:10

I\'m trying to calculate the total, mean and median of an array thats populated by input received by a textfield. I\'ve managed to work out the total and the mean, I just ca

14条回答
  •  天涯浪人
    2020-12-05 07:10

    Check out the Arrays.sort methods:

    http://docs.oracle.com/javase/6/docs/api/java/util/Arrays.html

    You should also really abstract finding the median into its own method, and just return the value to the calling method. This will make testing your code much easier.

提交回复
热议问题