Java Session – Using Java8’s new features to coding is awesome



It's been three month since I started blogging. Even though I keep It one Update every week, But the amount of pageviews is still very low.

One day, a friend who started writing a blog with me at the same time, told me that the structure of my articles was too much like the tone of a government announcement, which would be boring.

So starting with this article, I'm going to make a transition and try to write it in a casual way.


Java8's new features do you understand?

At the same level as object-oriented programming: Functional programming

For Simplified the code: Lambda expression

Completely change the collection usage: Streaming API

Instead of the Swing: JavaFX API

Finally updated time/date library: java.time API

Supports asynchronous programming: CompletableFutures

Let your program not be NullPointException: Optional

Some enhancements to existing apis

So that's the new feature of Java8, and how much do you know about it?​


Change your object-oriented thinking to functional programming

The idea of using functional programming is to make all the work easy and the writing program can be better maintained.

Functional programming is easier to understand than object-oriented programming, and logically, code is much more understandable than object-oriented programming.

Functional programming is a method that takes zero to more parameters and generates a result, And there are no side effects.

The best way to understand this is to think of it as a black box that accepts parameter input and output result, One of the most important concepts is that when you make multiple calls with the same parameter, the results are always the same.


Lambda expressions you really scare me

Maybe a lot of people like me, always avoid to understand what is called Lambda expressions, but believe me, please be sure to learn and master as soon as possible, and then you'll find that your code like "poetry".

The first benefit of using Lambda expressions is that you can remove all anonymous inner classes from your code and replace them with simple, understandable Lambda expressions.


Let's get to this point today, and let my words simmer in my head.​

Pere Tang. 2am on July 9, 2017



Java 8 in Action

Leave a Reply