Pages

Determine what package from a class object ???

Source code below will print name for package that belong to it's own class object. It should print null because class object that create from java file below not belong to any package.

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


public class DeterminePackageForClassObject
{
public static void main(String[]args)
{
try
{
Class temp=Class.forName("DeterminePackageForClassObject");
System.out.println("PACKAGE FOR THIS CLASS OBJECT IS :"+temp.getPackage());
}
catch(Exception exception)
{
exception.printStackTrace();
}
}
}


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