I have a very large list of objects and I want to count number of objects based on one of their attribute. what I have right now is:
long low = myList.stream().filter(p -> p.getRate().equals("Low")).count();
long medium = myList.stream().filter(p -> p.getRate().equals("Medium")).count();
long high = myList.stream().filter(p -> p.getRate().equals("High")).count();
I am not sure how Java 8 handles this but I am worried about performances! Is there anyway so I can count these 3 attributes in one call? in order to improve performance?
Something so that it returns a Map or list of object.