Using Java Reflection APIs you can retrieve superClass name, it's simple name,packagename, implemented interfaces and many more.
Key points to retrieve SuperClass Information :
Java Program to get Super Class Information using Java Reflection APIs:
Key points to retrieve SuperClass Information :
- Create Object of class which has super class
- Get SuperClass using getSuperClass()
- Get SuperClass name using getName()
- Get SuperClass simple name using getSimpleName().
- Get SuperClass PackageName using getPackage()
- Get interfaces using getInterfaces()
Java Program to get Super Class Information using Java Reflection APIs:
List list = new ArrayList(); System.out.println("\nSuper Class Information"); Class superClass = originalClass.getSuperclass(); System.out.println("ClassName - " + superClass.getName()); System.out.println("Simple Name - " + superClass.getSimpleName()); System.out.println("PackageName - " + superClass.getPackage()); Class[] sinterfaces = superClass.getInterfaces(); System.out.println("Implemented Interfaces - "); for (int i = 0; i < sinterfaces.length; i++) { System.out.println(sinterfaces[i].getName()); }Output :
Super Class Information ClassName - java.util.AbstractList Simple Name - AbstractList PackageName - package java.util, Java Platform API Specification, version 1.7 Implemented Interfaces - java.util.List
No comments:
Post a Comment