Get generic interfaces in Java

Description

The following code shows how to get generic interfaces.

Example


/*from w ww .ja v a 2s . c  om*/
import java.lang.reflect.Type;

import javax.xml.transform.sax.SAXSource;

public class Main {

  public static void main(String[] args) {
    try {
      Type[] ts = SAXSource.class.getGenericInterfaces();
      for (int i = 0; i < ts.length; i++) {
        System.out.println(ts[i]);
      }
    } catch (SecurityException e) {
      e.printStackTrace();
    }
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Reflection »




Annotation
Array
Class
Constructor
Field
Generics
Interface
Method
Modifier
Package
Proxy