Java Functional Interface

From bibbleWiki
Revision as of 00:24, 4 July 2025 by Iwiseman (talk | contribs) (Created page with "=Functional Interface= A functional interface is an interface that contains only one abstract method. They can have only one functionality to exhibit. =Java Example= Before Java 8, we had to create anonymous inner class objects or implement these interfaces. <syntaxhighlight lang="java"> // Java program to demonstrate functional interface class Test { public static void main(String args[]) { // create anonymous inner class object new Thread(ne...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Functional Interface

A functional interface is an interface that contains only one abstract method. They can have only one functionality to exhibit.

Java Example

Before Java 8, we had to create anonymous inner class objects or implement these interfaces.

 
// Java program to demonstrate functional interface
  
class Test
{
    public static void main(String args[])
    {
        // create anonymous inner class object
        new Thread(new Runnable()
        {
            @Override
            public void run()
            {
                System.out.println("New thread created");
            }
        }).start();
    }
}