Home » Tag Archives: Java 8 (page 3)

Tag Archives: Java 8

Joining Strings in JDK 8

java-logo

JDK 8 introduced language features such as lambda expressions, streams, and even the new Date/Time API that will change the way we write Java applications. However, there are also several new APIs and features that might be less “game changing,” but still bring greater convenience and expressiveness to the Java programming language. In this post, I look at one of ...

Read More »

Java 8 pitfall – Beware of Files.lines()

java-logo

There’s a really nice new feature in Java8 which allows you to get a stream of Strings from a file in a one liner.                   List lines = Files.lines(path).collect(Collectors.toList()); You can manipulate the Stream as you would with any other Stream for example you might want to filter() or map() or limit() ...

Read More »

Value-Based Classes

java-logo

In Java 8 some classes got a small note in Javadoc stating they are value-based classes. This includes a link to a short explanation and some limitations about what not to do with them. This is easily overlooked and if you do that, it will likely break your code in subtle ways in future Java releases. To prevent that I ...

Read More »

Default methods and multiple inheritance

java-logo

Recently Lukas JOOQ Eder posted and article about nested classes and their use. This is an interesting topic and his article is, as always, interesting and worth reading. There was only one slight statement I could not agree with and we had a brief reply chain leading to default method and why there can not be something like     ...

Read More »

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 »
Want to take your Java Skills to the next level?
Grab our programming books for FREE!
  • Save time by leveraging our field-tested solutions to common problems.
  • The books cover a wide range of topics, from JPA and JUnit, to JMeter and Android.
  • Each book comes as a standalone guide (with source code provided), so that you use it as reference.
Last Step ...

Where should we send the free eBooks?

Good Work!
To download the books, please verify your email address by following the instructions found on the email we just sent you.