import org.eclipse.collections.api.list.ImmutableList; import org.eclipse.collections.impl.factory.Lists; public class Example { public static void main(String[] args) { ImmutableList<Integer> numbers = Lists.immutable.of(1, 2, 3, 4, 5); numbers.select(n -> n % 2 == 0) .each(System.out::println); int sum = numbers.collect(n -> n * 2) .injectInto(0, Integer::sum); System.out.println("Sum: " + sum); } }


上一篇:
下一篇:
切换中文