title: Java Reflection, Getting attribute Names and Types
body: <p>I m facing problem while retriving fields types in class.</p>
  
  <pre><code>class Test {
      public int x;
      public int[] y;
      public String[] names;
  }
  
  public class Main {
      static void main(String[] args) {
          try {
              printAttributes(Class.forName("Test"));
          }
          catch(Exception ex){}
      }
  
      static void printAttributes(Class clazz) {
          Field[] fields=clazz.getFields();
          for (int i = 0; i &amp;lt; fields.length; i++) {
              System.out.println(fields[i].getType().getName().toString()+" "+ fields[i].getName().toString());
          }
      }
  }
  </code></pre>
  
  <p><strong>Output</strong></p>
  
  <pre><code>int x  //its OK
  [I y    //I need **int[] y**
  [Ljava.lang.String; names  //I need  **java.lang.String[] names**
  </code></pre>
  
  <p>How can I get the attribute types in correct format?</p>