WHAT IS REFLECTION IN JAVA ?

Mayank Tripathi

Total Post:807

Points:4035
Posted by  Mayank Tripathi
 545  View(s)
Ratings:
Rate this:
  1. Mayank Tripathi

    Post:807

    Points:4035
    What is reflection in Java ?

    If a programmer wants to access entities or invoke methods in a program dynamically, i.e. if the programmer is unaware of the methods and variables that needs to be invoked at runtime but unaware of it while coding, we can use reflection. For example
    Method method = ABC.getClass().getMethod("doSomething", null);
    method.invoke(ABC, null);

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!