Get Generic Super class in Java

Description

The following code shows how to get Generic Super class.

Example


/*from  w  w w.  j  a va  2 s  .  c o m*/
import java.lang.reflect.Type;
import java.util.ArrayList;

import javax.xml.transform.sax.SAXSource;

public class Main {

    public static void main(String[] args) throws Exception{
            Class< ? super SAXSource> ts = SAXSource.class.getSuperclass();
            System.out.println(ts);        
            Type t = ArrayList.class.getGenericSuperclass();
            System.out.println(t);        
            Class[] is = SAXSource.class.getInterfaces();
            for(int i=0;i<is.length;i++){
                System.out.println(is[i]);        
            }       
    }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Reflection »




Annotation
Array
Class
Constructor
Field
Generics
Interface
Method
Modifier
Package
Proxy