Lets say I have two lists of cars, and I want to stream through them, firstly checking they are the same type, and then and compare them based on some features, and depending on the outcomes I will perform some logic.
for(Car newCar : newCarLot) {
for(Car oldCar : oldCarLot) {
if(oldCar.getType() == newCar.getType()) {
if(oldCar.getTransmission() == newCar.getTransmission()) {
// do something, for example println
}
if(oldCar.getColour() == newCar.getColour()) {
// do something else
}
}
}
}
How would I perform this in streams?