Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

public class Main {
    public static void main(String[] args) {
        // Integer's sum
        MyCal<Integer> myOwnCalculatorFI = (a, b) -> (a + b);

        Integer sum = myOwnCalculatorFI.calcIt(5, 5);

        System.out.println("Sum: " + sum);

        // String's sum
        MyCal<String> myOwnCalculatorFI1 = (e, f) -> (e + f);
        System.out.println("Adder: " + myOwnCalculatorFI1.calcIt("a", "b"));

        // Double's power
        MyCal<Double> calculator2 = (a, b) -> (Math.pow(a, b));
        System.out.println("Integer's range: " + calculator2.calcIt(2D, 32D));
    }
}

interface MyCal<T> {

    public T calcIt(T t1, T t2);
}