String repersentation of Class
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Rajneesh_Garg
Posted On:   Wednesday, February 6, 2002 01:55 AM

To get the String repersentation of AClass class, I have come across this code

			
String strClassName = AClass.class.getName();

However, I fail to know about class in the Javadocs.
Also, how is above code working?
Rajneesh Garg


RGarg@Indiatimes.com

Re: String repersentation of Class

Posted By:   Steve_Long  
Posted On:   Wednesday, February 6, 2002 06:53 PM


perhaps you could be more clear about what you mean by "string representation of a class". the getName() function returns the class name as a string. if the class is a record structure, as most are, one is not obtaining a string representation of the class members, which may be implemented by overriding the toString() function for a class. toString() is inherited from Object but should be overridden in any class where an actual string representation of the class members is desired.

Re: String repersentation of Class

Posted By:   Duncan_Forster  
Posted On:   Wednesday, February 6, 2002 02:49 AM

The {object}.class syntax comes from the original java implementations. Since then it has changed and the correct way to do this now is {object}.getClass(). You can still use the old way because Sun didn't want to break old code but it's not advised.
About | Sitemap | Contact