Tuesday, May 3, 2016

JAVA 8 - what is Functional Interface and Lambda Expression, etc

Functional Interface is an interface with only one method.
- default methods do not count
- static methods do not count
- methods from the Object class do not count

A Lambda Expression is an instance of a functional interface.
public interface Predicate<T> {
    boolean test(T t);
}

Implementation would be:
Predicate<String> predicate = s -> s.length() < 20;
System.out.println(predicate.test("Hello world!"));//expicite way of using it