Write a Java program to demonstrate the use of a functional interface with lambdas and method references
@FunctionalInterface interface Operation { int perform(int a, int b); } public class Main { public static int add(int a, int b) { return a + b; } public static void main(String[] args) { Operation addition = (a, b) -> a + b; Operation subtraction = Main::add; System.out.println("Addition : " + addition.perform(4, 3)); System.out.println("Subtraction : " + subtraction.perform(10, 7)); } }
Addition : 7 Subtraction : 17
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions