Question: Required Skills Inventory Write a method that take a arguments and returns a value Write a method that takes an ArrayList as an argument Use

Required Skills Inventory
Write a method that take a arguments and returns a value
Write a method that takes an ArrayList as an argument
Use a loop to get the computer to repeat instructions
Use a loop to iterate over the elements of an ArrayList
Use an if statement to get the computer to make a decision
Use a variable to keep a count
Problem Description and Given Info
Write (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
public class Main {
public static void main(String[] args){
// you may wish to write some code in this main method
// to test your method.
}
}

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!