使用基本返回类型的泛型方法 [英] Use of generic method with primitive return type
本文介绍了使用基本返回类型的泛型方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public class Util< K,V> {
public static< K,V>布尔比较(Pair p1,Pair p2){
}
}
我知道为什么我们使用 Util
但是 static
?。我从链接中获得。请帮我理解。
解决方案
分开这个。 < K,V>
是方法参数。 static
是使方法成为静态的修饰符,即您可以在不创建对象的情况下调用它。
只要阅读一些关于java,方法,类,静态方法等内容。
public class Util<K,V> {
public static <K, V> boolean compare(Pair<K, V> p1, Pair<K, V> p2) {
}
}
I know why we are using Util<K,V>
but what is the use of static <K,V>
?.I got this from link. Please help me to understand.
解决方案
Separate this. <K, V>
are method parameters. static
is a modifier that makes method "static", i.e. you can invoke it without creating object.
Just read something about java, methods, classes, static methods etc.
这篇关于使用基本返回类型的泛型方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文