clean code

Why and How to Use Optional in Java

The Optional object type in Java was introduced with version 8 of Java. It is used when we want to express that a value might not be known (yet) or it’s not applicable at this moment. Before Java 8 developers might have been tempted to return a null value in this case. Ultimately, there are… read more »

Use Lambdas Instead of Anonymous Classes In Java

Another useful feature introduced since Java 8 is the possibility to use lambdas instead of anonymous classes. Here is an example: Imagine you have the following list of names: If you want to sort it alphabetically ignoring the case, you would have to use a Comparator and implement its compare method in an anonymous class… read more »

Sidebar