Answers for "Java 8 Functional Interfaces"

1

creating the functional interface in java

package com.concretepage;

@FunctionalInterface
public interface Calculator {
   long calculate(long num1, long num2);
}
Posted by: Guest on February-17-2020
0

functional interface in java 8 example

@FunctionalInterface
interface Square
{
    int calculate(int x);
}
  
class Test
{
    public static void main(String args[])
    {
        int a = 5;
  
        // lambda expression to define the calculate method
        Square s = (int x)->x*x;
  
        // parameter passed and return type must be
        // same as defined in the prototype
        int ans = s.calculate(a);
        System.out.println(ans);
    }
}
Posted by: Guest on June-28-2021
1

interface function

interface SearchFunc {
  (source: string, subString: string): boolean;
}
Posted by: Guest on August-20-2020
0

Java 8 Functional Interfaces

Supplier       ()    -> x
Consumer       x     -> ()
Callable       ()    -> x throws ex
Runnable       ()    -> ()
Function       x     -> y
BiFunction     x,y   -> z
Predicate      x     -> boolean
UnaryOperator  x1    -> x2
BinaryOperator x1,x2 -> x3
Posted by: Guest on August-11-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language