If you are using functional interface using Lambda expression in your code and you get the below error, that's because your expression does not return the datatype which the Function Interface method expects,
Example: Functional Interfacepackage org.code2care;
@FunctionalInterface
public interface Validate {
public boolean isString(Object object);
}
Example: Lambda expression
package org.code2care;
public class Example {
public static void main(String[] args) {
Validate validate = object -> object.toString();
Validate validate1 = object -> object.toString().length();
System.out.println(validate.isString("Java"));
}
}
Error:
As you can see the reason for the complication error is isString(Object obj) returns a boolean and not java.lang.String or an int

Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!