So I’m writing this code. I would like to check if say my object is instanceof class that I put in as parameter. My code should explain itself.
public boolean same(Item item, Class cls) {
//this is were I don't know if it is possible to achieve.
return item instanceof cls.getType(); // cls.getType() doesn't exist.
}
So is there a way to convert that cls object to a type ?
I could do this other way and stuff, but this seems to be the “cleanest way” if it would be possible to achieve.