How to get an average from a constantly variable voltage level from an analog in

...put?

I am using the jSerialComm API from Fazecast to get a voltage level to Java from the serial port. How can I use a loop to get a mean from a constant voltage level. I want to get a mean of every 50 readings.

https://forum.arduino.cc/index.php?topic=444247.0

Although if the voltage is constant, why would you need to get an average?