Question: Write java ( define ) a public static method named count, that takes an ArrayList of Integer, and an int as arguments and returns (

Write java (define) a public static method named count, that takes an ArrayList of Integer, and an int as arguments and returns (as an int) a count of the number of times the second argument value appears in the ArrayList.
For example:
given an ArrayList named myList that contains this list of values: {1,2,1,3,2,5,6,2,4}
count(myList,2) should return 3
count(myList,99) should return 0
You may wish to write some additional code to test your method.
Helpful Hints:
Use a loop to iterate over the elements of the argument ArrayList
For each element in the array, you must decide to either count it or not
Return the count at the end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!