Q:

android/java concept to call all getter methods with a single loop

I am doing an assignment and stuck at this point:
I have a class in which i have 30 getter and setter method. 
  public class example{

public String get1(){
 return someString1;
}

public String get2(){
return someString1;
}

public String get3(){
return someString4;
}

and so on...

public String get30(){
return someString30;
}

}

Now i want to call all getter method with a single loop like
for(int i= 1; i<=30;i++){
// String total = get1()+get2()+get3()...............
}

what should i do?
Edit: i did it using reflection :
http://docs.oracle.com/javase/tutorial/reflect/member/methodInvocation.html
Thanks Ricky

A:

The commented code is the only way to do that. But this is a symptom that your design is incorrect. Rather than having 30 properties of type String, you should certainly have one property of type String[] or List<String>.
Then you could do:
List<String> list = getListOfStrings();
StringBuilder builder = new StringBuilder();
for (String s : list) {
    builder.append(s);
}
String concatenation = builder.toString();

A:

I did it using reflection :
http://docs.oracle.com/javase/tutorial/reflect/member/methodInvocation.html

