Possible Duplicates:
Java Reflection: Getting fields and methods in declaration order
Java. Get declared methods in order they apear in source code
Suppose I have this class
Is possible take the getters methods in order?
public class ClassA {
private String name;
private Integer number;
private Boolean bool;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getNumber() {
return number;
}
public void setNumber(Integer number) {
this.number = number;
}
public Boolean getBool() {
return bool;
}
public void setBool(Boolean bool) {
this.bool = bool;
}
}
I have try this..
for (Method method : ClassA.class.getDeclaredMethods()) {
if (!(method.getReturnType().toString().equals("void"))) {
method.invoke(obj, new Object[0])));
}
}
I got this from documentation
...The elements in array returned are not sorted and are not in any particular order...
So.. is just that? Exists some alternative or I just have to implement something?