Selasa, 27 Juli 2021

How to Invoke Method by Name in Java Dynamically Using Reflection? Example

In Java you can invoke any method by its string name dynamically using reflection API. java.lang.reflect API provides powerful reflection mechanism which can load classes by its name even if classes are not available at compile time, Can get all methods including private and public from class and allow you to invoke any method dynamically using reflection. For those who are new to Java this sound pretty strange that at runtime you provide a method name using string and Java can run that method without any code for calling the method during compilation, but Reflection is such a powerful mechanism it allows to do a lot of stuff dynamically and if you been using IDE like Netbeans or Eclipse, a J2EE framework like Spring and Struts, these all used reflection to provide powerful configuration module and several other useful features like code assist etc.

Lorem ipsum is simply dummy text of the printing and typesetting industry.

Comments


EmoticonEmoticon