dcsimg
Given an object, is it possible to find out from which package it's class is?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Thursday, September 26, 2002 09:11 AM

Given an object, is it possible to find out from which package it's class is?

Re: Given an object, is it possible to find out from which package it's class is?

Posted By:   Alexander_Valdez  
Posted On:   Thursday, September 26, 2002 10:42 AM

Yes - the following is adapted from an example in the API javadoc:


void printClassName(Object obj) {
System.out.println("The class of " + obj +
" is " + obj.getClass().getName());
System.out.println("The package of " + obj +
" is " + obj.getClass().getPackage().getName());
}
About | Sitemap | Contact