I have a populated object(animalObj) of class Animal.
Animal class have methods like
- getAnimal1()
- getAnimal2() etc.
So i need to dynamically call these method FROM the object animalObj.
what i required is the implementation of this
String abc="123";
for(int i=0; i<abc.length(); i++)
animalObj.getAnimal+abc.charAt(i)+();
I know the about code is rubbish, but i need to know how to implement this.
I read about reflection in java and saw some questions like Java dynamic function calling, How do I invoke a Java method when given the method name as a string?.
But here all the questions are not dealing with populated object.
Any suggestions?