我有一个关于 Java 泛型编程的小问题。有没有办法检查传递给方法的参数的类型?我想比较调用该方法的实例的类型以及传递给它的参数。
如果它们不相同,则应停止该方法的操作(一种保护)。
public void homeMatch(SportTeam<Type> visitors){
if(the type of visitors and this-object are not the same){
//do this
}
else{
//do something different
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句