How to Use a Functional Interface in Java

A functional interface is an interface that contains a single abstract method. It is used as the basis for lambda expressions in functional programming. Such an interface may contain also other non-abstract methods even though this is not considered a good practice. Also, the notation @FunctionalInterface is optional but it will ensure that the intention… 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 »