Can someone help explain to me what each line of code does? public static int[] countLetters(char[] chars) { int[] counts = new int[26]; for (int i = 0; i


Can someone help explain to me what each line of code does?


public static int[] countLetters(char[] chars) {

int[] counts = new int[26];



for (int i = 0; i < chars.length;="">
counts[chars[i] - 'a']++;


return counts;
}





public static void displayCounts(int[] counts) {
for (int i = 0; i < counts.length;="" i++)="">
if ((i + 1) % 10 == 0)
System.out.println(counts[i] + " " + (char)(i + 'a'));
else
System.out.print(counts[i] + " " + (char)(i + 'a') + " ");
}
}
}



Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here