Dynamic Invocation
Navigate Reflection topic: ) |
We start with basic transfer object:
Code listing 10.1: DummyTo.java
package com.test;
public class DummyTo {
private String name;
private String address;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public DummyTo(String name, String address) {
this.name = name;
this.address = address;
}
public DummyTo() {
this.name = new String();
this.address = new String();
}
public String toString(String appendBefore) {
return appendBefore + " " + name + ", " + address;
}
}
|
Following is the example for invoking method from the above mentioned to dynamically. Code is self explanatory.
|
|
Conclusion: Above examples demonstrate the invocation of method dynamically using reflection.