How to pass a type parameterized interface to a method?

How should I pass a type parameterized interface to a method because java compiler errors out on following code saying “Can not resolve symbol T” in “callTwoParFunc” method signature!

class Test{

    interface TwoParFunc<T>{
        T func(T a, T b);
    }

    public void callTwoParFunc(TwoParFunc<T> f, T a, T b) {
        f.func(a, b);
    }
}

Answer

You need to add the <T> parameter to the method signature:

public <T> void callTwoParFunc(TwoParFunc<T> f, T a, T b) {
    f.func(a, b);
}