Question: write static methods for the following: countOf - This method should take an integer, target, and an ArrayList of integer, nums, as formal parameters and

write static methods for the following:
countOf - This method should take an integer, target, and an ArrayList of integer, nums, as formal parameters and should return an int indicating the number of times target appears in nums. If the given target is less than 0, then the method should return -1.
Example: countOf(2,[4,2,0,2,2]) should return the number 3(as the target number 2 appears 3 times in the list).
call it from the main at least once.

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!