入门小白求问(新手贴,若有不合规范请指出,谢谢了):
Java里instance method "private static <K> void methodName() {}" 中的<K>是什么意思?
这里的return不是void吗? 为什么有<K>呢?
问题出处: Data Structures and Algorithms in Java™ Sixth Edition Michael T. Goodrich...page:537(array-based merge-sort)
code:
public static <K> void merge(K[] S1, K[] S2, K[] S, Comparator<K> comp) {
int i = 0, j = 0;
while(i + j < S.length) {
if (j == S2.length || (i<S1.length && comp.compare(S1[i], S2[j]<0))
S[i+j] = S[i++];
else
S[i+j]=S2[j++];
}
}
多谢各位回答, 找到一个很详细的介绍:http://blog.csdn.net/jungle_h...