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.

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation