In the previous phrase, we show you how to find the superclasses associated with a given class. Superclasses are related to inheritance and the class extension mechanism in Java. In addition to extending a class, in Java you can implement an interface. Through reflection, you can also find which interfaces a given class has implemented. After you've obtained a Class object, you can use the getInterfaces() method to get the class's interfaces if indeed the class implements any interfaces. The getInterfaces() method will return an array of Class objects. Each object in the array represents one interface implemented by the given class. You can use the getName() method on these Class objects to get the name of the interfaces implemented. |