Java 8 - Functional Interface vs Abstract class

codingenious picture codingenious · Nov 13, 2013 · Viewed 14.2k times · Source

I was exploring features of Java 8 and came across "Functional Interface".

As per my understanding, these interfaces can have some default implemented methods as :

@FunctionalInterface
public interface ComplexFunctionalInterface extends SimpleFuncInterface 
{
    default public void doSomeWork()
    {
        System.out.println("Doing some work in interface impl...");
    }
    default public void doSomeOtherWork()
    {
        System.out.println("Doing some other work in interface impl...");
    }
}

But my doubt is, this what abstract class is for.

Why introduce functional interfaces.

Answer

yamafontes picture yamafontes · Nov 13, 2013

But my doubt is, this what abstract class is for.

Why introduce functional interfaces.

Number of classes that can be extended: 1

Number of interfaces that can be implemented: more than 1