0
I need to limit the output size of my Linkedhashmap:
It receives an undetermined number of information that needs to be reduced to no max 20 records:
I put a limit on the function below, but I had no results.
Map <String, ReportLine> map = new LinkedHashMap();
skuOrderCount.entrySet().stream()
.sorted(Map.Entry.comparingByValue(Comparator.comparing(ReportLine::getTotalCount).reversed()))
.limit(20)
.forEach(entry -> {
map.put(entry.getKey(), entry.getValue());
});
Does anyone have any idea ?
In reality the mistake was entirely mine, nor did I need to use its logic. My mistake was to insert in a foreach the instance of my linkedList, instead of the map shown above. But thank you very much ermão.abrrss
– Rodrigo Nantes