I need to create a condition to know if a given object is part of a class that implements a certain interface. How can I do this?
I need to create a condition to know if a given object is part of a class that implements a certain interface. How can I do this?
See this answer also, follow the examples:
interface I1 { }
interface I2 { }
class C implements I1, I2 { }
C c = new C();
boolean isC = (c instanceof C); //true
boolean isI1 = (c instanceof I1); //true
boolean isI2 = (c instanceof I2); //true