What that line does is create a new array of type
char with the size of the integer representation of the character returned from the method invocation... doesn't do much good for what you are trying to achieve
Look at this section of code carefully:
If we carefully study what it does then we can probably fill in the void within the if statement
- We are looping through the length of the
string... that mean if we have the string
"Java" we are looping 4 times since it is made up of four characters
- For each iteration we are checking to see if the character in the string at index
k is a letter... if its a letter we want to know what letter it is so we can increment the slot in the array that's keeping our running count of occurrences
We have the following array to keep our running count
This was set up because we know there are 26 letters in the alphabet so incrementing index 0 will say that we found an 'A' or 'a'... incrementing index 1 will say that we found a 'B' or 'b' etc...
In order to know which index in the array to increment within the if statement we came up with an algorithm that say since we are in the if statement its a letter so get the letter, transform it to lowercase and subtract
'a' from it to get the array subscript and increment
This is what you need to do in words... now transform it to working Java code