If you do not mind using a third-party library, you can use powerful new collections.
// import javaslang.collection.*; listB = listA.map(f);
These Java 8 collections are immutable and can be compared to those of Scala and Clojure. Please read here .
Btw - there is also syntactic sugar for for-loops:
// import static javaslang.API.*; // import javaslang.collection.Stream; Stream<R> result = For(iterable1, ..., iterableN).yield((e1, ..., eN) -> ...);
Disclaimer: I am the creator of Javaslang.
source share