I have a list of number, types is Double. I have a method to pass in the Double as params. I want to compare the input params with each of the values in the collection, if it matches the most closest value then return that value from the collection.
Collections<Double> list = new ArrayList<Double>();
list.add(89000.00);
list.add(78900.00);
list.add(56999.12);
so the method is like this
private Double getTheMatch(Double param) {
pseudo code:
for (Double d : list) {
if (param Match list.getNumber) {
return list.getNumber;
}
}
}
so if passing 88908.00 --> value will return will be 89000.00 , the most match value from the list
What API
java class should I use? Thanks