Pages

Get class name from class object ???

*****************************************************************
COMPLETE SOURCE CODE FOR : GetClassNameFromClassObject.java
*****************************************************************


public class GetClassNameFromClassObject
{
public static void main(String[]args)
{
try
{
//For example of this source code, we will use java predefined class named Object

//You can change class name instead of java.lang.Object
Class a=Class.forName("java.lang.Object");

//Now we will print the name of the class
System.out.println("IT'S NAME IS : "+a.getSimpleName());
}

catch(Exception exception)
{
exception.printStackTrace();
}
}
}


*****************************************************************
JUST COMPILE AND EXECUTE IT
*****************************************************************
Related Posts Plugin for WordPress, Blogger...