Guest User

Untitled

a guest
Apr 26th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. public class Car{
  2. String make;
  3. String model;
  4. String year;
  5. String price;
  6. }
  7.  
  8. Map<String, Car> youCarMap = yourCarList.stream().collect(
  9. Collectors.toMap(c->c.getMake(), c->c));
  10.  
  11. Map<String, Car> youCarMap = yourCarList.stream().collect(
  12. Collectors.toMap(c->c.getMake(), c->c, (oldValue, newValue) -> oldValue)));
  13.  
  14. cars.stream()
  15. .collect(Collectors.toMap(
  16. car -> car.make,
  17. Function.identity()
  18. )
Add Comment
Please, Sign In to add comment