Java: Lazy initialize a collection with Optional

In this short advice I would like to show you how to create null-safe code when working with unset data in a Java Bean or some API that you are using which may return a null reference. It will be an easy to read one liner.

How to hash data with Java MessageDigest

Let’s have a look at the Java Security MessageDigest class that provides one-way hash functions and how to get individual MessageDigest instances without using Strings for the algorithm names everywhere in our code.