Optimize insertion from ArrayList to HashMap
The Language class needs the &quot;addItem()&quot; method that combines incrementing numberItems and adding to the Items collection. The design intent here would be to hide the implementation details of adding an item.

The Language class needs a constructor for the first item added.
 Language language = new Language(item);


The languages map should be a specialization class of the HashMap, with its &quot;add(item)&quot; method to hide details of the new/existing item logic.