Java Class.getGenericSuperclass()

Syntax

Class.getGenericSuperclass() has the following syntax.

public Type getGenericSuperclass()

Example

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


//from ww w.  ja  va2  s  . co m
import java.lang.reflect.*;
import java.util.ArrayList;

public class Main {

  public static void main(String args[]) {

    Type t = IntegerClass.class.getGenericSuperclass();
    System.out.println(t);

    ParameterizedType p = (ParameterizedType) t;
    System.out.println(p.getActualTypeArguments()[0]);
  }
}

class IntegerClass extends ArrayList<Integer> {
  public IntegerClass() {
    // no argument constructor
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable