-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Learn Java with Projects
By :
Now, let’s examine some popular functional interfaces defined in the API. Interestingly, the two sorting interfaces from Chapter 13, namely Comparator and Comparable, are both functional interfaces. Comparable defines one abstract method, namely int compareTo(T o), and Comparator defines two abstract methods, namely int compare(T o1, T o2) and boolean equals(Object o). Remember, however, that methods inherited from Object do not count when you’re deciding if an interface is a functional interface or not. As boolean equals(Object o) is inherited from Object, this means that Comparator is a functional interface.
In this section, we will concentrate on the functional interfaces defined in the java.util.function package (https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/function/package-summary.html). This package has a large number of general-purpose functional interfaces that are used by the JDK and are...