Online Java Compiler By
JavaTpoint.com
//import statements... import java.lang.reflect.*; import java.util.ArrayList; public class ClassgetGenericSuperClassExample2 { public static void main(String args[]) { Type tp1 = Float1.class.getGenericSuperclass(); System.out.println(tp1); ParameterizedType pt1 = (ParameterizedType)tp1; System.out.println(pt1.getActualTypeArguments()[0]); System.out.println("------------------------------------------------------"); Type tp2 = String1.class.getGenericSuperclass(); System.out.println(tp2); ParameterizedType pt2 = (ParameterizedType)tp2; System.out.println(pt2.getActualTypeArguments()[0]); } } class Float1 extends ArrayList
{ public Float1() { } } class String1 extends ArrayList
{ public String1() { } }
Output