List<Integer> result = new ArrayList<>();
for (Car car : cars) {
    if (car.isDiesel()) {
        result.add(car.getMpg());
    }
}