I am writing a method were I would like to pass a class to a method, where a part of the code includes checking if the object is of a certain type. This is what I want (but which obviously doesn't work):
private static class MyClass1 { /***/ }
private static class MyClass2 { /***/ }
private void someFunc() {
/* some code */
methodName(MyClass1);
methodName(MyClass2);
}
private void methodName(Class myClass) {
Object obj;
/* Complicated code to find obj in datastructure */
if (obj instanceof myClass) {
/* Do stuff */
}
}
Any hints as to how this can be done? Thanks!