I\'m trying to think of some code that will allow me to search through my ArrayList and detect any values outside the common range of \"good values.\"
Example: 100 1
It is just a very simple implementation which fetches the information which numbers are not in the range:
List notInRangeNumbers = new ArrayList();
for (Integer number : numbers) {
if (!isInRange(number)) {
// call with a predefined factor value, here example value = 5
notInRangeNumbers.add(number, 5);
}
}
Additionally inside the isInRange method you have to define what do you mean by 'good values'. Below you will find an examplary implementation.
private boolean isInRange(Integer number, int aroundFactor) {
//TODO the implementation of the 'in range condition'
// here the example implementation
return number <= 100 + aroundFactor && number >= 100 - aroundFactor;
}