请告诉我如何转换:
Map<String, List<Pet>> pets = petList
.stream()
.collect(Collectors.groupingBy(Pet::getType));
在
Map<String, PetsHouse>
有帮助stream
吗?还是我很费心并在不使用流的情况下做出决定?
PetHouse
- 它只是床单上的一个包装纸
List<Pet> petList;
PetHouse house = new PetHouse(petList);
一切都解决了: