Monday, June 4, 2018

what do you mean by reflection in java?

Problem statement: what do you mean by reflection in java?

Reflection is an API which is used to examine or modify the behaviour of methods, classes, interfaces at Runtime.
  • The required classes for reflection are provided under java.lang.reflect package.
  • Reflection gives us information about the class to which an object belongs and also the methods of that class which can be executed by using the object.
  • Through reflection we can invoke methods at runtime irrespective of the access specifier used with them.

Reflection can be used to get information about –
  1. Class The getClass() method is used to get the name of the class to which an object belongs.
  2. Constructors The getConstructors() method is used to get the public constructors of the class to which an object belongs.
  3. Methods The getMethods() method is used to get the public methods of the class to which an objects belongs.

No comments:

Post a Comment

How to run standalone mock server on local laptop

 Please download the standalone wiremock server from Direct download section at the bottom of the page.  Download and installation Feel fre...