Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Functional Interface - Java 8

    • 0
    • 2
    • 0
    • 2
    • 0
    • 0
    • 0
    • 0
    • 1.09k
    Comment on it

    The interface with only a single methods is known as functional interface. If an interface marked as @FunctionalInterface it can only contains one abstract method. If we try to declare more than one abstract method inside FunctionalInterface compiler will produce the error.

    For example -

    1. @FunctionalInterface
    2. public interface MyDemoFunctionalInterface {
    3. public abstract void display();
    4. }

    The above example is correct and will compile successfully, but the below example cannot be compiled and will throw the error:

    1. @FunctionalInterface
    2. public interface MyDemoFunctionalInterface
    3. {
    4. public abstract void display();
    5. public abstract void show();
    6. }

    Hope this will help you :)

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: