title: Is possible getMethods in order using reflections?
body: <blockquote>
    <p><strong>Possible Duplicates:</strong><br>
    <a href="https://stackoverflow.com/questions/5001172/java-reflection-getting-fields-and-methods-in-declaration-order">Java Reflection: Getting fields and methods in declaration order</a><br>
    <a href="https://stackoverflow.com/questions/3148274/java-get-declared-methods-in-order-they-apear-in-source-code">Java. Get declared methods in order they apear in source code</a>  </p>
  </blockquote>
  
  
  
  <p>Suppose I have this class</p>
  
  <p>Is possible take the getters methods in order?</p>
  
  <pre><code>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;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I have try this..</p>
  
  <pre><code>for (Method method : ClassA.class.getDeclaredMethods()) {
      if (!(method.getReturnType().toString().equals("void"))) {
          method.invoke(obj, new Object[0])));
      }
  }
  </code></pre>
  
  <p>I got this from documentation</p>
  
  <blockquote>
    <p>...The elements in array returned are not sorted and are not in any particular order...</p>
  </blockquote>
  
  <p>So.. is just that? Exists some alternative or I just have to implement something?</p>