So I have a program that counts the number of occurrences of each letter in a string, and for that I use
int[] charAmount = new int[30]; for(int i = 0; i<text.length(); i++){ char sign = text.charAt(i); int value = sign; if(value >= 97 && value <= 122){ charAmount[value-97]++; // 97 = 'a' } This works fine, but I also need to cover the letters 'æ' (230), 'ø' (248) & 'å' (229). How can I "assign" those three letters to the 26, 27 & 29th index of the charAmount array without using if tests or a switch?
EDIT: The code presented above is not the whole block, I also have a switch for the letters in question, but I am looking for a better solution.
BONUS PROBLEM: When I try to enter a string like "æææ" or something, the value of 'æ' is suddenly 8216. I use a Scanner to read the input.
Mapfor further extensibility