Java - Lambda Expressions

package com.test;

public class Lambda {

        public static void main(String[] args) {
                Runner r = new Runner();
                r.run((x, y) -> {
                        System.out.println("Lambda expression executed");
                        System.out.println("hello world");
                        return 5 + x;
                });

                r.run((x, y) -> {

                        return 5 - x;
                });

                r.run((x, y) -> 5 * x);

                r.run((x, y) -> 5 * x + y);
        }

}

interface Executable {

        int execute(int x, int y);
}

class Runner {

        public void run(Executable e) {
                System.out.println("inside run method");
                System.out.println(e.execute(12, 2));
        }

        public int getVal() {
                return 10;
        }
}

Technology: 

Search