Getting the Pair class implemented interfaces

In order to obtain the interfaces that are directly implemented by a class or interface represented by an object, we simply call Class.getInterfaces(). This method returns an array. Since the Pair class implements a single interface (Comparable), the returned array will contain a single element:

Class<?>[] interfaces = clazz.getInterfaces();

// interface java.lang.Comparable
System.out.println("Interfaces: " + Arrays.toString(interfaces));

// Comparable
System.out.println("Interface simple name: "
+ interfaces[0].getSimpleName());
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.5.57