
Please solve How to convert a string type data to as a method name? For Ex:
collTypeCatList = new ArrayList<CollTypeCategory>(); for(int i=1;i<=collTypeCatMasterList.size();i++){ //here i got a list size String str="custStatsMaster.getcusts"+i+"()"; //i have methods like custs1,cust2,.... CollTypeCategory collTypeCategory1 = new CollTypeCategory(); collTypeCategory1.setTitle("DISTRIBUTOR"); collTypeCategory1.setCustomers(str);//here i have to execute methods(but it takes like //string type) collTypeCatList.add(collTypeCategory1); }
Adv. Thanks....

Here is an example that stores the class object into arraylist and display them.
import java.util.*;
class Employee{
public int id;
public String name;
public String address;
public Employee(){}
public Employee(int id, String name,String address) {
this.id = id;
this.name = name;
this.address=address;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public String getAddress() {
return address;
}
}
public class Example{
public static void main(String[] args) throws Exception {
List<Employee> list = new ArrayList<Employee>();
list.add(new Employee(1, "A","Delhi"));
list.add(new Employee(2, "B","Mumbai"));
list.add(new Employee(3, "C","Chennai"));
list.add(new Employee(4, "D","Kolkata"));
System.out.println(" ");
for (Employee s : list){
System.out.println(s.getName()+" \t " +s.getAddress());
}
}
}