I realy don t know what to do anymore! This code do the job but still... :D
Any hints? Tk you!
package com.codegym.task.task10.task1012;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/*
Number of letters
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
// Alphabet
String abc = "abcdefghijklmnopqrstuvwxyz";
char[] abcArray = abc.toCharArray();
ArrayList<Character> alphabet = new ArrayList<>();
for (char letter : abcArray) {
alphabet.add(letter);
}
// Read in strings
ArrayList<String> list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
String s = reader.readLine();
list.add(s.toLowerCase());
}
// write your code here
Map<Character, Integer> map = new HashMap<>();
StringBuilder a = new StringBuilder();
for(String s : list){
a.append(s);
}
for (Character c : alphabet) {
map.put(c, 0);
}
for(int i = 0; i < a.length(); i++){
Character c = a.charAt(i);
map.replace(c, map.get(c)+1);
}
for(Map.Entry<Character, Integer> pairs : map.entrySet()){
Character c = pairs.getKey();
Integer n = pairs.getValue();
System.out.println(c+ " " +n);
}
}
}