int [] numList = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int rangeLowerBound = 2
int rangeUpperbound = 8
Is there some sort of standard way to grab a group of numbers from the array that fall within the range, then put those numbers into a new Array?
int [] numList = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int rangeLowerBound = 2
int rangeUpperbound = 8
Is there some sort of standard way to grab a group of numbers from the array that fall within the range, then put those numbers into a new Array?
Assuming this range is inclusive,
int[] inRange = Arrays.stream(numList).filter(x -> x >= rangeLowerBound && x <= rangeUpperbound).toArray();
// inRange = [2, 3, 4, 5, 6, 7, 8]