Design the static method below to count and return the frequency of each digit in the array of strings.
public static int [ ] countFreq (String [ ] strings);
in order to find the frequency of characters in an alphabet, we do this; i want to know how to count the frequency of the digits using that static method. The program should be really simple.
//example: x = "abcabcABDEFabc0123A"
public class Q4
{
public static int [ ] count (String x)
{
int [ ] counters = new int [52];
for (int i = 0; i < 52; i++)
counters[i] = 0;
int len = x.length ( );
for (int i = 0; i < len; i++)
{
char c = x.charAt(i);
if ((c >= 'A') && (c <= 'Z'))
counters[c - 65]++;
else if ((c >= 'a') && (c <= 'z'))
counters[c - 71]++;
}
return counters;
}
}