I have a list of objects: a car that needs to be converted to a map.
Public Class Car { private Integer carId; private Integer companyId; private Boolean isConvertible; private String carName; private String color; private BigDecimal wheelBase; private BigDecimal clearance; }
I have another object that I want to consider as a map key.
public class Key<L, C, R> { private L left; private C center; private R right; }
I want to create a map from the "Car List" objects.
List<Car> cars; Map<Key, Car> -> This map contains Key object created from 3 field of Car object namely carId, companyId, isConvertible.
I can't figure out how to do this using Java 8 Lambda
cars.stream.collect(Collectors.toMap(?, (c) -> c);
In the above expression, instead of?, I want to create an object of class Key, using the values ββpresent in the current object of the car. How can I achieve this?
java dictionary list lambda java-8
vaibhavvc1092
source share