• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

runtime information for a class

 
Arun Martin
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
To access runtime type information for a class, array, or primitive datatype, you can use the _________ class.
ClassLoader
Class
System
Object
Runtime
arun.
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer is "Class" class. This is a part of Java introspection facility using which you can retrieve the metadata a class is made of like names of methods, constructors, fields, their types etc.
Using the retrieved information, you can go one step further and invoke methods using dynamic dispatch.
Ajith
 
Anil Vupputuri
Ranch Hand
Posts: 527
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From JDK1.2, Java supports Reflection API,which is powerful
Using Reflection,enables Java code to discover information about the fields, methods and constructors of loaded classes, and to use reflected fields, methods, and constructors to operate on their underlying counterparts on objects, within security restrictions. The API accommodates applications that need access to either the public members of a target object (based on its runtime class) or the members declared by a given class.
Anil
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic