© Ralph Lecessi 2019
Ralph LecessiFunctional Interfaces in Javahttps://doi.org/10.1007/978-1-4842-4278-0_1

1. Functional Interfaces

Ralph Lecessi1 
(1)
Kendall Park, NJ, USA
 

Section 1.1: Interfaces in Java

In Java, an interface specifies one or more methods. The interface is a contract which must be honored by all implementing classes. The interface defined in Listing 1-1 specifies methods method1 and method2.
interface I1
{
    void method1();
    String method2(String x);
}
Listing 1-1

I1.java

Any class that implements an interface must provide implementations for all the methods declared in the interface (or the class must be declared as abstract). Since the class defined in Listing 1-2 provides implementations for both method1 and method2, objects of class ...

Get Functional Interfaces in Java: Fundamentals and Examples now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.