In this example I will show you how to use basic Java Reflection tricks to call a Java method from a String. This is a surprisingly simple task. You can find out more about the Java Reflection API on the Java Tutorial Trail.
First the code of the method:
Then the code to call the method through a String:
This will call the method “printMessage” and give it the Object with one object “Hello World”. The printMessage() method will then go through the Object and print them out.