I have an object.
public class Test{
int age;
LocalDateTime currentTime;
//class also contains getters and setters.
}
Lets assume I have a List and i need to calculate the mean age. I iterate though all, add values then divide by the size of the list. Now i need to calculate the difference between the age and the mean. If the difference between the age and mean repeats (is same between different objects in the list) then i need to remove the object with the earliest timestamp from the array.
I am stuck on how to do this. Initially i was thinking that i can just expand the Test class to store the difference then do a sort, but want to avoid this. The other options left were to store it in a Map or create a separate object for them but seems very messy.
Any other ideas on how to do this nicely?