Recently I’ve rediscovered Class.cast(object) that can be used to cast objects to a type. In Java 8 streams the method allows to do a nice Java casting trick.
Continue reading Java casting trickjava8
In this post we’ll show a practical example of processing tree-like structure using streams and Java 8 flatMap.
Continue reading Java 8 flatMap practical exampleThere are many ways to create Java Streams and for each of them we’ll show examples. This flexibility is needed especially when combined with flatMap!
Continue reading Create Java StreamsJava 8 Comparators with Method References in action. We mix Java 8 static and default methods with method references to sort objects by multiple fields using chained Comparators!
Continue reading Java 8 Comparators with Method ReferencesJava 8 Functional Interfaces is very important concept, because they are heavily used with Lambda Expressions and Streams to simplify code. Let’s take a deep dive!
Continue reading Java 8 Functional InterfacesIn Java 8 interfaces default and static methods are major changes that allow to extend existing code without breaking anything. It should be the first step into Java 8.
Continue reading Java 8 interfaces default and static methodsUntil Java 7 there was no simple and effective way to generate random numbers concurrently. Here we show ThreadLocalRandom to generate random numbers in a thread-safe way.
Continue reading Generate random numbers concurrently – ThreadLocalRandomJava 8 regular expressions have been improved with names for capturing groups. In this post we show how to used them to improve Java code maintainability!
Continue reading Java 8 regex match group – named capturing groupsIn Java 8 remove selected item from Collection? It can be done in at least two ways both of which we are going to implement here. Let’s code!
Continue reading Java 8 remove selected item from CollectionOne way to prevent concurrent modifications from different Threads is to given them their own local data. Java ThreadLocal allows to do thread data separation.
Continue reading Java ThreadLocal – thread data separation