Dynamic Invocation
< Java Programming < Reflection
Navigate Reflection topic: |
We start with basic transfer object:
![]() |
Code listing 10.1: DummyTo.java
1 package com.test;
2
3 public class DummyTo {
4 private String name;
5 private String address;
6
7 public String getName() {
8 return name;
9 }
10
11 public void setName(String name) {
12 this.name = name;
13 }
14
15 public String getAddress() {
16 return address;
17 }
18
19 public void setAddress(String address) {
20 this.address = address;
21 }
22
23 public DummyTo(String name, String address) {
24 this.name = name;
25 this.address = address;
26 }
27
28 public DummyTo() {
29 this.name = new String();
30 this.address = new String();
31 }
32
33 public String toString(String appendBefore) {
34 return appendBefore + " " + name + ", " + address;
35 }
36 }
|
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.
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.