February 2014
Intermediate to advanced
160 pages
4h 59m
English
Efficiency got a boost in Java 8; we can be lazy and postpone execution of code until we need it. We can delay initialization of heavyweight resources and easily implement the virtual proxy pattern. Likewise, we can delay evaluation of method arguments to make the calls more efficient. The real heroes of the improved JDK are the Stream interface and the related classes. We can exploit their lazy behaviors to create infinite collections with just a few lines of code. That means highly expressive, concise code to perform complex operations that we couldn’t even imagine in Java before.
In the next chapter we’ll look at the roles lambda expressions play in optimizing recursions.