<p>If I have two variables:</p>

<pre><code>Object obj;
String methodName = "getName";
</code></pre>

<p>Without knowing the class of <code>obj</code>, how can I call the method identified by <code>methodName</code> on it?</p>

<p>The method being called has no parameters, and a <code>String</code> return value. It's <em>a getter for a Java bean</em>.</p>

Use
method invocation
from reflection:
```
```
Class<?> c = Class.forName("class name");
Method method = c.getDeclaredMethod("method name", parameterTypes);
method.invoke(objectToInvokeOn, params);
```
```
Where:
```
"class name"
```
is the name of the class
```
objectToInvokeOn
```
is of type Object and is the object you want to invoke the method on
```
"method name"
```
is the name of the method you want to call
```
parameterTypes
```
is of type
```
Class[]
```
and declares the parameters the method takes
```
params
```
is of type
```
Object[]
```
and declares the parameters to be passed to the method