Javatpoint Logo
Javatpoint Logo

Creating a program that works as javap tool

Following methods of java.lang.Class class can be used to display the metadata of a class.

MethodDescription
public Field[] getDeclaredFields()throws SecurityException returns an array of Field objects reflecting all the fields declared by the class or interface represented by this Class object.
public Constructor[] getDeclaredConstructors()throws SecurityException returns an array of Constructor objects reflecting all the constructors declared by the class represented by this Class object.
public Method[] getDeclaredMethods()throws SecurityException returns an array of Method objects reflecting all the methods declared by the class or interface represented by this Class object.

Example of creating javap tool

Let's create a program that works like javap tool.

At runtime, you can get the details of any class, it may be user-defined or pre-defined class.

Output:

creating a program that works like javap tool creating a program that works like javap tool

Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA