Question: Complete the method countCharkey that accepts two parameters: a 2D array of characters and a char key. The method should return a 1D array of

Complete the method countCharkey that accepts two parameters: a 2D array of characters and a char key. The method should return a 1D array of integers where each element in the 1D array represents the number of occurrences of the key in the corresponding row of the 2D array. The rows of the 2D array might not all be the same size (i.e., it might be a "ragged" array). For example, if passed the 2D array {{'a', 'b', 'c'}, {'a', 'd', 'b', 'a', 'z'}, {'w', 'x', 'y', 'z'} } and the key 'a, the method should return the array:{1, 2,0}. public static int[] countCharkey (char [][] array, char key) {
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
