Reference no: EM132154792
Use the ArrayList and Collections classes to accomplish each of the following tasks.
Assume that the ArrayList contains Integer values.
Remember when reading the Collections class API that ArrayList can be used for anything that is a List or a Collection. Don't worry about the crazy <? extends T> or similar syntax-everything that is logical to do is legal here. When you see Object or T, Integer can be used.
a) Write a method to remove all of the elements in list of Integers that are less than some target value. For example, if list initially contained {-1, 2, -1, 0, 0, 0, 5} and the target was 1, the list would contain {2, 5} after the method. Pass the list by sharing.
b) Write a method that finds the number of times the least common element in an ArrayList<Integer> occurred. If the list contained: {-1, 2, -1, 0, -5}, the method would return 1 because 0, 2, and 5 occurred just once.