'How am I able to increase the index of a char array?
I am trying to count the frequency of words in a String s that consists of only lowercase letters. For as long as I've known how, I do it like this:
int[] freq = new int[26];
for (int i = 0; i < s.length(); i++) {
freq[s.charAt(i)]++;
}
However, I am seeing that this is possible as well:
char[] freq = new char[26];
for (int i = 0; i < s.length(); i++) {
freq[s.charAt(i)]++;
}
How am I able to add 1 to the value of a char array? And when I print out the values of the char array, I am seeing nothing.
Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
