I have an Arraylist as follows , I need to count the number of occurrences for all of the elements in the Arraylist, knowing that the content of the Arraylist may change according to the user input. i.e : the user in the second time may enter(C and D)
ArrayList<String> letters = new ArrayList<String>();
letters.add("A");
letters.add("B");
letters.add("A");
letters.add("B");