Home » Tag Archives: Java 8 (page 7)

Tag Archives: Java 8

Mapreduce in Java8

Wordcount is to Mapreduce what “Hello world” is for rest of the programming world. Recently I have been exploring some of the more prominent Java 8’s features like Lambda, Streams and Optionals, so I thought it’d be nice to do a simplified version of Wordcount in Java. Java’s Stream and Lambda functions makes it really easy and concise to implement ...

Read More »

Using Java 8 Lambda expressions in Java 7 or older

I think nobody declines the usefulness of Lambda expressions, introduced by Java 8. However, many projects are stuck with Java 7 or even older versions. Upgrading can be time consuming and costly. If third party components are incompatible with Java 8 upgrading might not be possible at all. Besides that, the whole Android platform is stuck on Java 6 and ...

Read More »

Joining Strings in JDK 8

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()

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

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

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

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

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 »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns