Question : java using the segment Information already before the for-loop
Answered by : phuong-anh-dang
Map<String, List<Item>> items = new HashMap<>();
items.computeIfAbsent(key, k -> new ArrayList<>()).add(item);
Source : https://stackoverflow.com/questions/12134687/how-to-add-element-into-arraylist-in-hashmap/12134802 | Last Update : Sat, 26 Feb 22