I’m try to do something like this
public void method(Object obj, Class objClass) {
if(obj instanceof objClass) {
//do something
}
}
I want to pass Class object or class name and test if that is and instanceof of that.
This don’t work, anyone know how to do this?
Thanks
You can use the
isInstancemethod ofClass.So you would write
If you want to do this generically, you can use
.castto convert to the type represented byobjClass.