我想验证发送给方法的参数,它必须是接口类型。要问什么?
void (Class<I> interfaceType){
if (thisisnotaninterface){
throw...
}
}
我想验证发送给方法的参数,它必须是接口类型。要问什么?
void (Class<I> interfaceType){
if (thisisnotaninterface){
throw...
}
}
您有一种Class#isInterface()
方法可以完全满足您的要求:-
if (!interfaceType.isInterface()) {
throw...
}
只是Class#isInterface()
用来检查
说真的,您应该先阅读 Javadocs,然后再在这里提问。