Breaking News
Home / Java / Java Snippets / Invoke a method of class using Java Reflection API

Invoke a method of class using Java Reflection API

Java Reflection ExampleThis snippet shows how to invoke a method of class using Java Reflection API. The example uses a class called TargetClass that has a instance method named as runMe(). Now from the main method, this class will be loaded via the System Classloader and then instantiated using the newInstance() method. Then finally using the Reflection API and then the runMe() method would be invoked on created instance.

 [pb_builder]

Check Also

How to progamatically get the Java version?

Snippet The key here is to use the system property java.version and get minor and …

Advertisment ad adsense adlogger