This is a beginner's question. Regarding declaring a generic method, what is the point of have a type parameter in front of the return type? Let me simply quote the example from Oracle Java tutorial
public class Util {
public static <K, V> boolean compare(Pair<K, V> p1, Pair<K, V> p2) {
return p1.getKey().equals(p2.getKey()) &&
p1.getValue().equals(p2.getValue());
}
}
Let's say since the types of the parameters have been declared inside the method parameter list, i.e., Pair<K, V> p1 and Pair<K, V> p2, and we expect the method to return a value of boolean type. As I suppose that we care mostly about the return value, why do we still have to explicitly insert a type parameter <K, V> in the method declaration?