Loop through your array and check if the number is within the given range (min number for example is nine and max number is 30). Add it to a newly created array then return the array when you’re done. I’ll provide a code snipit shortly.
public ArrayList<Integer> withinRange(int min, int max, int[]array){
ArrayList<Integer> list = new ArrayList<>();
for(int i : array){
if(i>=min && i<=max){
list.add(i);
}
}
return list;
}
This will include the min and the max in your answer.
1
solved Getting all the values from an array in between a range