A more generic way, how to retrieve the name of the class (that is used in the program) that reflects the package name by using the getName() method. Here is an example that provides the proper way to use the getName() method.
Retrieving the class name through Reflection API
A more generic way, how to retrieve the name of the class (that is used in the program) that reflects the package name by using the getName() method. Here is an example that provides the proper way to use the getName() method.
Here we create an object of class Fclass and assign the reference of the class java.util.Integer.class to it. Now retrieve the class name (that is included in the program) by using the getName() method.
Here is the code of the Example :
Fclass.java
import java.lang.reflect.*;
|
Here is the output of the Example :
C:\roseindia>javac Fclass.java C:\roseindia>java Fclass java.lang.Integer |