Java Reflection - Java Class.getGenericInterfaces()








Syntax

Class.getGenericInterfaces() has the following syntax.

public Type [] getGenericInterfaces()

Example

In the following code shows how to use Class.getGenericInterfaces() method.

/*from w  w  w.  jav  a2 s .com*/
import java.lang.reflect.Type;

public class Main {

  public static void main(String[] args) {

    Main d = new Main();
    Class c = d.getClass();

    Type[] t = c.getGenericInterfaces();
    if (t.length != 0) {
      for (Type val : t) {
        System.out.println(val.toString());
      }
    } else {
      System.out.println("Interfaces are not implemented...");
    }
  }
}

The code above generates the following result.