Java 8 StringJoiner demo

Finally Java has convenient and intuitive API for joining strings with delimiters! Since Java 8 there is StringJoiner class. It is an API that you may know from Guava Joiner classes (see my post: https://looksok.wordpress.com/2015/10/17/guava-joiner-join-all-strings-in-an-array-or-map/). Here is a short StringJoiner demo. Basic String joins The most basic usage is to create StringJoiner instance with delimiter … Continue reading Java 8 StringJoiner demo

Java 8 Streams demo

Why streams? Nearly every Java app iterates collections, making operations on its elements, searching, changing them, sorting and so on. Streams are more readable way of doing this. Streams operations are to some excent similar to SQL Query operations - you can select, filter, order items in collection. What is a stream Stream is a … Continue reading Java 8 Streams demo

Java 8 news: Default Interface method example & argumentation

Java 8 introduces significant changes. One of them are default methods in interfaces. What has changed Before Java 8, the interface must not have any method implementation - only the headers. Since Java 8 the interface can have method implementations. These are called the default methods and does not have to be overriden in implementation … Continue reading Java 8 news: Default Interface method example & argumentation

Java 8: Lambda expression example

Lambda expression are a short-form replacement for anonymous classes. They help in cases where you have to declare an interface with a single abstract method (such an interface is called functional interface) and its implementation. In short words The function is now an Object since Java 8. It is now the first-class citizen, like primitives … Continue reading Java 8: Lambda expression example