Write (define) a public static method named countInRange, that takes an ArrayList of Integer, and two additional intarguments and returns (as an int) a count of the number values in the ArrayList that are between the second and third argument values (inclusive). You can safely assume that the third argument value will always be greater than or equal to the second argument value. For example: given an ArrayList named myList that contains this list of values: {1, 2, 1, 3, 2, 5, 6, 2, 4} countInRange(myList, 1, 6) should return 9 countInRange(myList, 2, 4) should return 5 countInRange(myList, 10, 20) should return 0 -------------------------------------------------------------------- public class Main { public static void main(String[] args) { // you may wish to write some code in this main method // to test your method. } }
Write (define) a public static method named countInRange, that takes an ArrayList of Integer, and two additional intarguments and returns (as an int) a count of the number values in the ArrayList that are between the second and third argument values (inclusive). You can safely assume that the third argument value will always be greater than or equal to the second argument value.
For example:
given an ArrayList<Integer> named myList that contains this list of values: {1, 2, 1, 3, 2, 5, 6, 2, 4}
countInRange(myList, 1, 6) should return 9
countInRange(myList, 2, 4) should return 5
countInRange(myList, 10, 20) should return 0
--------------------------------------------------------------------
public class Main {
public static void main(String[] args) {
// you may wish to write some code in this main method
// to test your method.
}
<your method definition here>
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images