Java Functional Interfaces. java.util.function Package: Different ways of Reading a text file in Java, Write Interview code. A functional interface can have any number of default methods. They are defined with generic types and are re-usable for specific use cases. Hence this functional interface which takes in 2 … In this post, we will learn the Java 8 the functional interface with examples. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. Of course, there are also specializations of UnaryOperator and BinaryOperator that can be used with primitive values, namely DoubleUnaryOperator, IntUnaryOperator, LongUnaryOperator, DoubleBinaryOperator, IntBinaryOperator, and LongBinaryOperator. Fallowing the article about simple Partial Function application in Java, I had made a simple experiment with handling the varags methods using lambdas and functional interfaces. We'll simulate that using Guava's sleepUninterruptibly method: Another use case for the Supplier is defining a logic for sequence generation. The java.util.function package in Java 8 contains many builtin functional interfaces like-. Lambda expression works on functional interfaces to replace anonymous classes. The Supplier functional interface is yet another Function specialization that does not take any arguments. The Function Interface is a part of the java.util.function package which has been introduced since Java 8, to implement functional programming in Java. T - the type of results supplied by this supplier. A prominent example is the Runnable and Callable interfaces that are used in concurrency APIs. One such Functional Interface is the Predicate interface which is defined as follows – As in all previous examples, there are IntPredicate, DoublePredicate and LongPredicate versions of this function that receive primitive values. Functional Interfaces In Java. How to Create Interfaces in Android Studio? Parameter Passing Techniques in Java with Examples, Different ways of Method Overloading in Java, Constructor Chaining In Java with Examples, Private Constructors and Singleton Classes in Java, Access specifiers for classes or interfaces in Java. An interface with only one abstract method is a functional interface. Experience. The lambda passed to the List.forEach method implements the Consumer functional interface: There are also specialized versions of the Consumer — DoubleConsumer, IntConsumer and LongConsumer — that receive primitive values as arguments. Java 8 has defined a lot of functional interfaces in java.util.function package. A functional interface is an interface with only one abstract method. BiFunction has both arguments and a return type generified, while ToDoubleBiFunction and others allow you to return a primitive value. Please write to us at contribute@geeksforgeeks.org to report any issue with the above content. From Java 8 onwards, lambda expressions can be used to represent the instance of a functional interface. 5. e.g. The simplest definition is: Functional Interfaces are Java Interfaces with only a single abstract method. Java 8 offers Lambda expressions to help us write better, and concise codes. A complete list of all functional interfaces in the Java API, including argument and return types and javadoc links. The java.util.function package contains many builtin functional interfaces in Java 8. TimeZoneNameProvider: provides localized time zone names for the TimeZoneclass. The use of this annotation is optional. Operator interfaces are special cases of a function that receive and return the same value type. From Java 8 onwards, lambda expressions can be used to represent the instance of a functional interface. NumberFormatProvider: provides monetary, integer and percentage values for … What are Functional Interfaces? Runnable, ActionListener, Comparable are some of the examples of functional interfaces. Converting Java functional interfaces to C#. The Supplier functional interface is yet another Function specialization that does not take any arguments. It has a Single Abstract Method (SAM) test(), which accepts the generic object type T and returns a boolean.. Java Predicate Example 2. This article is a guide to different functional interfaces present in Java 8, their general use cases and usage in the standard JDK library. It represents a function which takes in one argument and produces a result. More interesting is the BiConsumer interface. Notice that to be useful as a generator, the Supplier usually needs some sort of external state. Functional interfaces provide target types for lambda … Let us see the implementation of functional interface in Java − Example @FunctionalInterface public interface MyInterface { void invoke(); } public class Demo { void method(){ MyInterface x = -> MyFunc (); x.invoke(); } void MyFunc() { } } To fit the purpose, the lambda used to transform the values of a list has to return the same result type as it receives. How to convert an Array to String in Java? To calculate a value, it uses the passed Function implementation: A value, in this case, will be calculated by applying a function to a key, put inside a map and also returned from a method call. That's all, From now this can be used with Lambda. It is typically used for lazy generation of values. In Java 8 these interfaces are also marked with a @FunctionalInterface annotation. Runnable interface is an example of a Functional Interface. The source code for the article is available over on GitHub. The contract of the different algorithm implementations does not need a dedicated interface. The predicate interface is located in java.util.function package. Lambdas, functional interfaces and best practices of working with them, in general, are described in the article “Lambda Expressions and Functional Interfaces: Tips and Best Practices”. To understand the value of generic functional interfaces, consider the two different functional interfaces, one called StringYear and the other called IntYear : Both interface defined a method called getYear( ) that returned a result. Functional interfaces can also be created by inheriting another functional interface. This not only clearly communicates the purpose of this interface, but also allows a compiler to generate an error if the annotated interface does not satisfy the conditions. They can have only one functionality to exhibit. A functional interface has exactly one abstract method. Similarly, a Functional Interface is an interface with just one abstract method declared in it. Functional interface can be initialized using lambda expressions, method references, or constructor references. This article is contributed by Akash Ojha .If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. By using our site, you A new package called java.util.function was created to host these common functions. Functional interfaces are those interfaces that has single abstract method. It is a function that is representing side effects. The Predicate functional interface is a specialization of a Function that receives a generified value and returns a boolean. This is where Java’s functional Consumer interface comes in handy. So, what are Functional Interfaces? Don’t stop learning now. All functional interfaces are recommended to have an informative @FunctionalInterface annotation. The UnaryOperator interface receives a single argument. The article explains how to convert an Iterable to Stream and why the Iterable interface doesn't support it directly. Functional Interface: This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference. It can also declare methods of the object class. For instance, let's define a function that squares a double value. Other specializations of Supplier functional interface include BooleanSupplier, DoubleSupplier, LongSupplier and IntSupplier, whose return types are corresponding primitives. Functional interfaces have a single functionality to exhibit. Passed function must be associative, which means that the order of value aggregation does not matter, i.e. Learn how to apply if/else logic to Java 8 Streams. Instead, we can describe it using the existing java.util.function.Function interface. To demonstrate it, let’s use a static Stream.generate method to create a Stream of Fibonacci numbers: The function that is passed to the Stream.generate method implements the Supplier functional interface. The high level overview of all the articles on the site. Since a primitive type can’t be a generic type argument, there are versions of the Function interface for most used primitive types double, int, long, and their combinations in argument and return types: There is no out-of-the-box functional interface for, say, a function that takes a short and returns a byte, but nothing stops you from writing your own: Now we can write a method that transforms an array of short to an array of byte using a rule defined by a ShortToByteFunction: Here’s how we could use it to transform an array of shorts to array of bytes multiplied by 2: To define lambdas with two arguments, we have to use additional interfaces that contain “Bi” keyword in their names: BiFunction, ToDoubleBiFunction, ToIntBiFunction, and ToLongBiFunction. The designers of Java 8 have captured the common use cases and created a library of functions for them. Here is a Java functional interface example: Newly defined functional interfaces in Java 8 in java.util.function package – These are pre-defined Functional Interfaces introduced in Java 8. Functional interface provides target types for lambda expressions and method references. Why Java Interfaces Cannot Have Constructor But Abstract Classes Can Have? This is why the UnaryOperator is useful here. 4. The canonical reference for building a production grade API with Spring. A new concept introduced in Java 8, functional interfaces were added to support lambda expressions. The different algorithms composing the family of … In case more than one abstract methods are present, the compiler flags an ‘Unexpected @FunctionalInterface annotation’ message. Focus on the new OAuth2 stack in Spring Security 5. You can find more detail about them in Java 8 Stream Example . Let's use a BiFunction implementation that receives a key and an old value to calculate a new value for the salary and return it. An Interface that contains exactly one abstract method is known … Many interfaces from previous versions of Java conform to the constraints of a FunctionalInterface and can be used as lambdas. It has only run() method declared in it. close, link Java provides many SPIs, here are some samples of the service provider interface and the service that it provides: 1. In Java 8, single abstract method interfaces are known as functional interfaces. Using Java 8 functional interfaces. Remember that an object on which the method is invoked is, in fact, the implicit first argument of a method, which allows casting an instance method length reference to a Function interface: The Function interface has also a default compose method that allows to combine several functions into one and execute them sequentially: The quoteIntToString function is a combination of the quote function applied to a result of the intToString function. For instance, let’s greet everybody in a list of names by printing the greeting in the console. Java 8 has a new package “java.util.function” that contains many functional interfaces, the most known and used functional interfaces being Predicate, Consumer, Supplier, Function. A typical use case of the Predicate lambda is to filter a collection of values: In the code above we filter a list using the Stream API and keep only names that start with the letter “A”. There are a lot of re-usable functional requirements that can be captured by functional interfaces and lambdas. Generic Functional Interfaces It is possible to declare generic functional interfaces. The filtering logic is encapsulated in the Predicate implementation. Java.util.BitSet class methods in Java with Examples | Set 2, Java.io.BufferedInputStream class in Java, Java.io.ObjectInputStream Class in Java | Set 1, Java.util.BitSet class in Java with Examples | Set 1, Java.io.BufferedWriter class methods in Java, Java.io.StreamTokenizer Class in Java | Set 1, FICO ( Fair Issac and Corporation) | Set 1(On Campus), Split() String method in Java with examples, Different ways for Integer to String Conversions In Java. As a functional interface can have only one abstract method that's why it is also known as Single Abstract Method Interfaces or SAM Interfaces. The Predicate Functional interface takes a single input and returns a boolean value. Examples of a functional interface in Java are: It is typically used for lazy generation of values. One of its use cases in the Collections API is to replace all values in a list with some computed values of the same type: The List.replaceAll function returns void, as it replaces the values in place. Comparator is a functional interface even though it declared two abstract methods. The arguments of this function are a pair of values of the same type, and a function itself contains a logic for joining them in a single value of the same type. See your article appearing on the GeeksforGeeks main page and help other Geeks. Java 8 brought a powerful new syntactic improvement in the form of lambda expressions. The java.util.function.Consumer class has one non-default method named accept which takes a … In our ITrade case, all we’re doing is checking the boolean value of business functionality based on a condition. edit Here follows a complete list of the functional interfaces available in the standard Java API. The most simple and general case of a lambda is a functional interface with a method that receives one value and returns another. Functional Interface is an interface with only single abstract method. Key points about the functional interface: An Interface that contains exactly one abstract method is known as a functional interface. C# Equivalent to Java Functional Interfaces. This allows us to greatly simplify concurrency code: In this article, we’ve described different functional interfaces present in the Java 8 API that can be used as lambda expressions. This is a functional interface which can be used with a lambda expression and method reference. However, it is not mandatory to use this annotation. Function is an inbuilt functional interface introduced in java 8 in the java.util.Function package, where T is generic input type and R is the type of output of the operation. It can have any number of default, static methods but can contain only one abstract method. With Stream API, we could do this using a collector, but a more generic way to do it would be to use the reduce method: The reduce method receives an initial accumulator value and a BinaryOperator function. Attention reader! Equivalent of Java’s Functional Interfaces in C# is Delegates. Built-in Functional Interfaces Java 8 introduced a lot of Functional Interfaces as part of JDK 8. Please use ide.geeksforgeeks.org, generate link and share the link here. From no experience to actually building stuff​. Functional Interfaces¶. This can be useful if the generation of this argument takes a considerable amount of time. How to add an element to an Array in Java? THE unique Spring Security education if you’re working with Java today. This can be useful if the generation of this argument takes a considerable amount of time. As opposed to the Supplier, the Consumer accepts a generified argument and returns nothing. This means that the interface implementation will only represent one behavior. 4. Java 8 introduced a new package : java.util.function.This package has many commonly used Functional Interfaces. Before Java 8, we had to create anonymous inner class objects or implement these interfaces. They can have only one functionality to exhibit. How to determine length or size of an Array in Java? In the first case, the return type was String. You can test a conditi… 3. Writing code in comment? the following condition should hold: The associative property of a BinaryOperator operator function allows to easily parallelize the reduction process. Any interface with a SAM(Single Abstract Method) is a functional interface, and its implementation may be treated as lambda expressions. By the way, we may replace the lambda with a method reference that matches passed and returned value types. You can observe this by looking at the Function's documentation. For instance, let's define a function that squares a double value. A functional interface in Java is an interface that contains only a single abstract (unimplemented) method. CurrencyNameProvider: provides localized currency symbols for the Currencyclass. Consequently, before defining a new one, it is advisable to check this package's … All are bundled into package java.util.function and total 43 functional interfaces. If an interface declares an abstract method overriding one of the public methods of java.lang.Object, that also does not count toward the interface’s abstract method count since any implementation of the interface will have an implementation from java.lang.Object or elsewhere. A functional interface is an interface that contains only one abstract method. It will receive not a value itself, but a Supplier of this value:This allows us to lazily generate the argument for invocation of this function using a Supplier implementation. @FunctionalInterface annotation is used to ensure that the functional interface can’t have more than one abstract method. Note: To create a custom Functional Interface, We must annotate the interface with @FunctionalInterface. The term Java functional interface was introduced in Java 8. A functional interface has only one abstract method but it can have multiple default methods. LocaleNameProvider: provides localized names for the Localeclass. According to Java 8 Specification, interface can be known as functional interface if there is a single method that is compliant with the below rules: If an interface has single abstract method, then it is known as the functional interface. To implement this state, we use an array instead of a couple of variables, because all external variables used inside the lambda have to be effectively final. A functional interface can have any number of default methods. The guides on building REST APIs with Spring. Functional Programming in Java with Examples, Access specifier of methods in interfaces, Two interfaces with same methods having same signature but different return types. @FunctionalInterface public interface Supplier. How to Use if/else Logic in Java 8 Streams, “Lambda Expressions and Functional Interfaces: Tips and Best Practices”. A Java Functional Interface is the one which can be used as Lambda expression. A functional interface is an interface that contains only one abstract method. For example, a Comparable … A functional interface can contain default and static methods which do have an implementation, in addition to the single unimplemented method. Before Java 8, you would usually create a class for every case where you needed to encapsulate a single piece of functionality. Lambda expressions revolve around Functional Interfaces. For functions that we can represent in a form of SAM interface: As mentioned in the previous post, you can assign in fact the variable argument method to any… brightness_4 The java.util.function package contains 40+ such interfaces. acknowledge that you have read and understood our, GATE CS Original Papers and Official Keys, ISRO CS Original Papers and Official Keys, ISRO CS Syllabus for Scientist/Engineer Exam, Difference between Abstract Class and Interface in Java, Comparator Interface in Java with Examples, Collection vs Collections in Java with Example, Java | Implementing Iterator and Iterable Interface, SortedSet Interface in Java with Examples, SortedMap Interface in Java with Examples, File Handling in Java with CRUD operations, Beginning Java programming with Hello World Example, Decision Making in Java (if, if-else, switch, break, continue, jump), StringBuilder Class in Java with Examples. Suppose we want to aggregate a collection of integers in a sum of all values. The benefit of a functional interface is that a developer can specify an anonymous implementation wherever a reference to the interface is required (for example, passing an implementation of the Runnable interface when instantiating a Thread object). Package java.util.function Description. Within this article, we’ll be covering what functional interfaces are and the reason why they were added to Java 8, as well as the benefits they provide. DateFormatProvider:provides date and time formats for a specified locale. This function of a single argument is represented by the Function interface which is parameterized by the types of its argument and a return value: One of the usages of the Function type in the standard library is the Map.computeIfAbsent method that returns a value from a map by key but calculates a value if a key is not already present in a map. Functional interface in Java 8 example program code in eclipse. Not all functional interfaces appeared in Java 8. In java 8 context, functional interface is an interface having exactly one abstract method called functional method to which the lambda expression’s parameter and return types are matched. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. The requirement is, it should have only one abstract method. According to the JavaDoc, the Consumer interface accepts any type of object as input. This guide focuses on some particular functional interfaces that are present in the java.util.function package. Represents a supplier of results. One of the typical examples of using this interface in the standard API is in the Map.replaceAll method, which allows replacing all values in a map with some computed value. A functional interface can have default methods. A functional interface is an interface annotated with @FunctionalInterface annotation and contains only one abstract method, but the interface can have multiple default methods. Some of the useful java 8 functional interfaces are Consumer , Supplier , Function and Predicate . Of course, instead of name -> name.toUpperCase(), you can simply use a method reference: One of the most interesting use cases of a BinaryOperator is a reduction operation. We use cookies to ensure you have the best browsing experience on our website. In this case, its state is comprised of two last Fibonacci sequence numbers. In mathematical logic, a predicate is a function that receives a value and returns a boolean value. A lambda is an anonymous function that can be handled as a first-class language citizen, for instance passed to or returned from a method. 4. @FunctionalInterface annotation is used to ensure an interface can’t have more than one abstract method. Java 8 onwards, we can assign lambda expression to its functional interface object like this: @FunctionalInterface Annotation It will receive not a value itself, but a Supplier of this value: This allows us to lazily generate the argument for invocation of this function using a Supplier implementation. One of its use cases is iterating through the entries of a map: Another set of specialized BiConsumer versions is comprised of ObjDoubleConsumer, ObjIntConsumer, and ObjLongConsumer which receive two arguments one of which is generified, and another is a primitive type. This implied a lot of unnecessary boilerplate code to define something that served as a primitive function representation. The closest C# equivalent to Java's functional interfaces are C# delegates. Note that Java 8's default methods are not abstract and do not count: a functional interface may still have multiple default methods. Used in concurrency APIs generic types and are re-usable for specific use cases associative, which means that the implementation. Runnable interface is an interface that contains exactly one abstract method ) is a part of the examples functional... All functional interfaces as part of the service provider interface and the service that it provides 1! Therefore be used with lambda, lambda expressions and method reference specialization that does not,. In Spring Security education if you ’ re doing is checking the boolean value IntPredicate, DoublePredicate and versions... Todoublebifunction and others allow you to return a primitive function representation why the Iterable does. The runnable and Callable interfaces that are used in concurrency APIs the associative of... Default, static methods which do have an informative @ FunctionalInterface annotation’.! Anonymous inner class objects or implement these interfaces it using the existing <... New syntactic improvement in the first case, all we ’ re with! Is defining a logic for sequence generation is, it should have only one abstract method is an that!, it is not mandatory java provider functional interface use this annotation had to create anonymous class! Information about the topic discussed above boolean value of business functionality based a... An interface with a SAM ( single abstract method considerable amount of time state is comprised of last! Java today this is where Java ’ s functional interfaces as part of the different algorithm implementations does need... In it 8, functional interfaces like- of value aggregation does not take any arguments one argument produces. Interfaces as part of the java.util.function package be created by inheriting another interface. Of functionality equivalent of Java ’ s functional interfaces were added to support lambda expressions contain only one abstract but. Any interface with only single abstract method all we ’ re doing is checking the boolean.. Method is a specialization of a FunctionalInterface and can therefore be used with method. Are IntPredicate, DoublePredicate and LongPredicate versions of this argument takes a single method. In all previous examples, there are IntPredicate, DoublePredicate and LongPredicate versions of this argument a! But it can also declare methods of the service that it provides 1. Same value type is: functional interfaces Java 8 introduced a new concept introduced in 8! Is checking the boolean value of business functionality based on a condition runnable interface is an interface that contains one. One which can be used with a SAM ( single abstract method but it can also methods... Can describe it using the existing java.util.function.Function < T, R > interface methods do., DoubleSupplier, LongSupplier and IntSupplier, whose return types are corresponding primitives that receive and return same... Was created to host these common functions Streams, “ lambda expressions can useful... Code for the Currencyclass Iterable to Stream and why the Iterable interface n't. The way, we had to create anonymous inner class objects or implement these interfaces are those that! A collection of integers in a sum of all the articles on the site sort! Produces a result arguments and a return type generified, while ToDoubleBiFunction and others allow you return. High level overview of all the articles on the site interface has only one method... The form of lambda expressions powerful new syntactic improvement in the form of lambda and... A sum of all the articles on the new OAuth2 stack in Spring Security 5 use. Inner class objects or implement these interfaces are special cases of a functional interface was introduced in 8! Types and are re-usable for specific use cases and created a library of for! 8 Stream example, lambda expressions and functional interfaces are recommended to have an informative @ FunctionalInterface message. With lambda methods are present, the Supplier, function and Predicate in all previous examples, there IntPredicate. Have multiple default methods is possible to declare generic functional interfaces are also marked a... Syntactic improvement in the java.util.function package contains 40+ such interfaces is defining logic... Interfaces to replace anonymous classes one non-default method named accept which takes in one and... Informative @ FunctionalInterface annotation a double value mathematical logic, a Predicate is a functional interface can! Easily parallelize the reduction process be associative, which means that the implementation! Created a library of functions for them topic discussed above a library of for. Annotation is used to ensure you have the best browsing experience on our website, and! The order of value aggregation does not matter, i.e let 's define a function that squares a java provider functional interface.... An informative @ FunctionalInterface annotation is used to ensure you have the best browsing experience on our website were... Specified locale arguments and a return type was String or method reference that matches passed and returned value.! The Consumer interface comes in handy are C # Delegates ActionListener, Comparable are some the... As a functional interface however, it is typically used for lazy generation values! Take any arguments function allows to easily parallelize the reduction process and value... The different algorithm implementations does not need a dedicated interface JDK 8 Spring Security education if you anything. Share more information about the topic discussed above another functional interface here are some samples of java.util.function! Piece of functionality complete list of the functional interface may still have multiple default methods let define... And method reference sequence generation @ FunctionalInterface annotation’ message best browsing experience on our website the with. As input method that receives one value and returns a boolean value of functionality! Initialized using lambda expressions, method references, or you want to share more about... > interface or you want to share more information about the topic discussed above guide focuses on some functional. Function which takes a single input and returns nothing specialization that does not a! To replace anonymous classes of business functionality based on a condition the term functional... Of all the articles on the GeeksforGeeks main page and help other Geeks type results! Contains 40+ such interfaces only represent one behavior expression or method reference standard Java.! Length or size of an Array in Java also declare methods of the interfaces! Represents a function that receives a value and returns another particular functional interfaces: generic functional interfaces are. Cases and created a library of functions for them needs some sort of external state have constructor but classes! Of JDK 8 the return type generified, while ToDoubleBiFunction and others allow you to return primitive. Formats for a specified locale multiple default methods which do have an @... A collection of integers in a sum of all values the console interface and the service provider interface the... Method named accept which takes a considerable amount of time at the function 's documentation 8 has defined lot! Actionlistener, Comparable are some samples of the service that it provides: 1 for use... Piece of functionality IntSupplier, whose return types are corresponding primitives are Java interfaces with only a single abstract unimplemented... Type was String associative property of a functional interface new OAuth2 stack Spring... A list of names by printing the greeting in the standard Java API of lambda expressions, references... Reference that matches passed java provider functional interface returned value types accepts any type of object as.... Which can be used as the assignment target for a lambda expression implementation, in to... Iterable interface does n't support it directly named accept which takes a single piece of functionality builtin. Simulate that using Guava 's sleepUninterruptibly method: another use case for the Supplier is defining a logic for generation! Return type was String marked with a @ FunctionalInterface annotation function that receives a value and a... Here are some of the functional interfaces available in the console simple and general case of function... Functionalinterface annotation’ message versions of this function that receive primitive values you to return a primitive function representation lambda! Case where you needed to encapsulate a single piece of functionality package which has introduced! The useful Java 8, functional interfaces are C # Delegates for lazy generation of values something that as... In Java is an example of a functional interface java provider functional interface contain default and static methods which do have implementation... And do not count: a functional interface example: generic functional interfaces complete list names... The Supplier, the compiler flags an ‘Unexpected @ FunctionalInterface annotation’ message mandatory to if/else... Ways of Reading a text file in Java of a BinaryOperator operator function allows to easily the. Unnecessary boilerplate code to define something that served as a generator, the java provider functional interface. Another functional interface: an interface with only one abstract method to Stream and why Iterable! Introduced since Java 8 brought a powerful new syntactic improvement in the java.util.function package are cases... Help us write better, and concise codes by inheriting another functional interface in Java 8 onwards, lambda.. Possible to declare generic functional interfaces available in the form of lambda expressions to help us better! From Java 8 onwards, lambda expressions and method references FunctionalInterface and can therefore be used with lambda! To Java 8 Streams term Java functional interface and returned value types is. These common functions one which can be used as lambda expression works on functional interfaces are C # equivalent Java. Whose return types are corresponding primitives and return the same value type created inheriting! Interface even though it declared two abstract methods are present in the Predicate functional interface is a Java functional is. This annotation Predicate implementation particular functional interfaces are special cases of a FunctionalInterface and can be... Abstract methods are not abstract and do not count: a functional interface may still have multiple default are.