Posts

Showing posts from June, 2013

Functional Interfaces in JDK8

FunctionalInterface is a new annotation that is being added to interfaces to allow SAMs to be compile time checked.  SAMs are Single Abstraction Methods which are nothing but interfaces with just a single method. Most common example of a SAM is a   Runnable  Interface   with a single run() method which gets anonymously instantiated . Other examples are AWT's EventListener classes. For detailed explanation on SAMs read   this Joe Darcy , the spec lead for lambda explains FunctionalInterfaces as "To a first approximation,   functional interfaces   are those interface types which define only a single method and are therefore usable in lambda expressions.  ". See   this   for a detailed explanation of @FunctionalInterfaces. The reasoning behind implementing @FunctionalInterface :   The new annotation type allows a library designer to clearly indicate the property of intending an interface type to be used with lambda expr...