Question: Please write code in Java 5) Given an integer array and an integer, the method below should return the count of the number of times
5) Given an integer array and an integer, the method below should return the count of the number of times the integer occurs in the array. Example calls and return values for the method are shown below. Write the code needed for the method to work as intended. Your method MUST use a traditional for-loop. (Nor a for-each loop) count ({4,5,1,3,1,8,2,1),1)3 count ({4,2,2,2,2,2},2)5 count ({3,5,5,9},2)0 public int count( int[] nums, int targetNum) 1 6) Given an Arraylist of integers, the method below should return the sum all integers in the ArrayList. Example calls and return values for the method are shown below. Write the code needed for the method to work as intended. Your method MUST use a for-each loop. sum({4,5,1})10sum({4,2})6sum({3,5,5,9})4 public int sum ( ArrayList nums) 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
