Tag: list comprehension

如何在List的每个元素上调用方法?

假设我有一个汽车列表: public class Car { private String brand; private String name; private String color; public Car() { // … } public getName() { return name; } // … } // Suppose that I have already init the list of car List cars = //… List names = new ArrayList(); for (Car c : cars ) […]