I wrote this method to calculating number of data usage. It receives LinkedList (historyDate)with data, then i add it to Set for avoiding duplicates and calculating key-value(data - count) in Map
public Map<String, Integer> countCodingsByDate() {
Set<String> dateCount = new HashSet<>(codingHistory.historyDate);
Map<String, Integer> dateOccurence = new HashMap<>();
for (String s : dateCount) {
int count = 0;
for (String a : codingHistory.historyDate) {
if (s.equals(a)) {
count++;
}
}
dateOccurence.put(s, count);
}
return dateOccurence;
}
Output:
{28-11-2019=5, 29-11-2019=3}
I have a qustion - in what way and how can i rework it with stream? Thank you for an answer