Create a Java program to demonstrate the use of a functional interface with a single abstract method
@FunctionalInterface interface Calculator { int calculate(int a, int b); } public class Main { public static void main(String[] args) { Calculator addition = (a, b) -> a + b; Calculator subtraction = (a, b) -> a - b; System.out.println("Addition : " + addition.calculate(5, 7)); System.out.println("Subtraction : " + subtraction.calculate(10, 4)); } }
Addition : 12 Subtraction : 6
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions