Home » Tag Archives: Java 8 (page 3)

Tag Archives: Java 8

Java8 Multi-threading ForkJoinPool: Dealing with exceptions

java-logo

One of the main motivations behind the introduction of Java8 lambdas was the ability to be able to use multicores as easily as possible (see Mastering Lambdas: Java Programming in a Multicore World).  By simply changing your code from collection.stream()... to collection.parallelStream()... you have instant multi-threading at your disposal which brings with it all the CPU power on your machine. ...

Read More »

Java 8 Optional is not just for replacing a null value

java-logo

Overview In Java 8, you can return an Optional instead of return null; as you might do in Java 7. This may or may not make a big difference depending on whether you tend to forget to check for null or whether you use static code analysis to check to nullalbe references. However, there is a more compelling case which ...

Read More »

Everything You Need To Know About Default Methods

java-logo

So, default methods… yesterday’s news, right? Yes but after a year of use, a lot of facts accumulated and I wanted to gather them in one place for those developers who are just starting to use them. And maybe even the experienced ones can find a detail or two they didn’t know about yet. I will extend this post in ...

Read More »

Reason for Slower Reading of Large Lines in JDK 7 and JDK 8

java-logo

I earlier posted the blog post Reading Large Lines Slower in JDK 7 and JDK 8 and there were some useful comments on the post describing the issue. This post provides more explanation regarding why the file reading demonstrated in that post (and used by Ant‘s LineContainsRegExp) is so much slower in Java 7 and Java 8 than in Java ...

Read More »

Java8 Lambdas: Sorting Performance Pitfall EXPLAINED

java-logo

Written in collaboration with Peter Lawrey. A few days ago I raised a serious problem with the performance of sorting using the new Java8 declarative style. See blogpost here.  In that post I only pointed out the issue but in this post I’m going to go a bit deeper into understanding and explaining the causes of the problem.  This will ...

Read More »

How to Translate SQL GROUP BY and Aggregations to Java 8

java-logo

I couldn’t resist. I have read this question by Hugo Prudente on Stack Overflow. And I knew there had to be a better way than what the JDK has to offer. The question reads:               I’m looking for a lambda to refine the data already retrieved. I have a raw resultset, if the user ...

Read More »

The Decorator Pattern With Java 8

java-design-patterns-logo_scaled

In a recent post I described how the decorator pattern saved my day. I gave a small code snippet which contained the simplest way to create decorators but promised that there would be a nicer way with Java 8. Here it is:               Decorating With Java 8 HyperlinkListener listener = this::changeHtmlViewBackgroundColor; listener = DecoratingHyperlinkListener.from(listener) ...

Read More »

Java 8 Functional Programming: Lazy Instantiation

java-logo

Singletons often instantiate themselves lazily, and sometimes, if the object is heavy enough, class fields can be instantiated lazily. Generally, when going the lazy route, the getter method (or accessor) has to have a block of code that checks whether the object is instantiated yet (and, if it isn’t, it needs to be instantiated) before returning it. This check is ...

Read More »

Using Java 8 to Prevent Excessively Wide Logs

java-logo

Some logs are there to be consumed by machines and kept forever. Other logs are there just to debug and to be consumed by humans. In the latter case, you often want to make sure that you don’t produce too much logs, especially not too wide logs, as many editors and other tools have problems once line lenghts exceed a ...

Read More »

Java Lambdas and Low Latency

java-logo

Overview The main question around the use of Lambdas in Java and Low Latency is; Does they produce garbage and is there anything you can do about it? Background I am working on a library which supports different wire protocols. The idea being that you can describe the data you want to write/read and the wire protocol determines if it ...

Read More »
Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close