I am studying generic methods, i just come to this code, and I can not seem to figure out why the following line of code does not compile
public static T genMethod(T t) {
return t;
}
You need to include <T>
in the method signature:
public static <T> T genMethod(T t) {
return t;
}
For reference, the docs