-2

I need explanation for the below questions:

  • What is reflection in java?
  • In which situation i need to use reflection?
  • Real time scenarios and examples for the need of using reflection?

I am very confused in reflection. I had read a lot of documents but I am still confused. Please give me a explanation where I can understand it completely.

Grodriguez
  • 21,501
  • 10
  • 63
  • 107
basith
  • 141
  • 1
  • 1
  • 6

1 Answers1

5
what is reflection in java?

Reflection makes it possible to inspect classes, interfaces, fields and methods at runtime, without knowing the names of the classes, methods etc. at compile time. It is also possible to instantiate new objects, invoke methods and get/set field values using reflection.

In which situation i need to use reflection? 

mapping objects to tables in a database at runtime.

Real time scenarios and examples for the need of using reflection? 

Good Real time example is MyEclipse IDE. if you put your mouse pointer over any class name it reflect the class name and with some information. This is also one type of reflection using reflection api.

Go through this Reflction API link you can get some more info.

Mdhar9e
  • 1,376
  • 4
  • 23
  • 46