Aricles related to

Java

Java 9 & 10: 4 new methods in the Optional API

One of the coolest things that where introduced in Java 8 was the Optional API. I've earlier written about how Optional can clean up your code. In short terms, Optional is a container object that may or may not contain a non-null value. It also offers a great range of…



Java 9: filtering and flatmapping - Two new collectors for your Streams

If you've worked with streams you've probably played around with the Collectors class. In earlier posts I've looked at how you can accumulate elements of a stream using Collectors as well as looking at how you can create a custom collector. In this post we're going to take a look…




How to generate a stream of random numbers in Java

From time to time you end up with the need of generating some random numbers. In Java, the Random class has been the go-to solution for this type of work. Random serves several helpful methods for creating random ints, doubles and longs. However, if you wanted a sequence of random…


Java 9: Cleaning up your default methods using private interface methods

Java 8 brought huge changes — one of them being the default interface methods. These methods changed interfaces as we knew them — we could now define default implementations in the interface itself. If you use these default methods heavily in your applications, you'll quickly figure out one thing — it doesn't really…


Java 9 - Making the Stream API even better

One of the first things I check out when looking at a new language is if it got a good collection API. I find that a good way of working with collections usually result in cleaner code that is easier to understand and reason about. That's why I was glad…