Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void printLetterDistribution() {
- int[] letterCount = new int[52];
- for(String s: notes) {
- for(char c: s.toCharArray()) { //Looked up the method .toCharArry() on stackoverflow
- if(c > 'A' && c < 'a') {
- letterCount[c-'A']++;
- }
- if(c > '`') {
- letterCount[c-'a' + 26]++;
- }
- }
- }
- for(int i = 0; i < 26; i++) {
- System.out.println((char)(i+'A') + ": " + letterCount[i] + "\t" + (char)(i+'a') + ": " + letterCount[i+26]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement