Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Car{
- String make;
- String model;
- String year;
- String price;
- }
- Map<String, Car> youCarMap = yourCarList.stream().collect(
- Collectors.toMap(c->c.getMake(), c->c));
- Map<String, Car> youCarMap = yourCarList.stream().collect(
- Collectors.toMap(c->c.getMake(), c->c, (oldValue, newValue) -> oldValue)));
- cars.stream()
- .collect(Collectors.toMap(
- car -> car.make,
- Function.identity()
- )
Add Comment
Please, Sign In to add comment