Java 8 brings with it some really big changes.
We will all know that you can call stream() on collections and then use methods such as map() or filter().
In this post I'd like to point out some of the lesser known features I've found useful in Java 8.
(Feel free to add your own lesser known Java 8 features in the comments).
A new static method for creating a ThreadLocal: ThreadLocal.withInitial()
private static ThreadLocal<Set<Date>> _holidays =
ThreadLocal.withInitial( ()->new HashSet<>() );
2) IntStream, LongStream and DoubleStream
It's worth having a look at these classes contained in java.util.stream
An alternative to a for loop:
Can easily be made parallel in this way: