Main.java
package com.company;

public class Main {

    interface IntegerMath {
        int operation(int a, int b); // Jeśli funkcja anonimowa, to może być tylko jedna
        default void domysl() {
            System.out.println("Funkcja domyślna");
        }

        default IntegerMath swap() {
            return (a, b) -> operation(b, a);
        }

    }
 
    private static int apply(int a, int b, IntegerMath op) {
        return op.operation(a, b);
    }

    public static void main(String... args) {

        // Wykorzystać podpowiedzi po Ctr Spacja
        /* 
        IntegerMath funkcja = new IntegerMath() { 
            @Override 
            public int operation(int a, int b) { 
                return 0; 
            } 
        }; 
 
        IntegerMath funkja2 = (a, b) -> 
         */

        IntegerMath funkcjaPLUS = new IntegerMath() {
            @Override
            public int operation(int a, int b) {
                return a + b;
            }
        };

        IntegerMath addition = (a, b) -> a + b;
        IntegerMath subtraction = (a, b) -> a - b;
        System.out.println("40 + 2 = " + apply(40, 2, addition));
        System.out.println("20 - 10 = " + apply(20, 10, subtraction));
        System.out.println("10 - 20 = " + apply(20, 10, subtraction.swap()));

        System.out.println("Suma anonimowa 2 + 4 = " + apply(2,4, (x,y) -> x + y));


        ((IntegerMath) (a, b) -> 0).domysl();


        System.out.println("40 + 13 = " + apply(40, 13, funkcjaPLUS));

    }
}