title: Get the Class Name of a Field from reflection
body: <p>Im going round in circles on this.</p>
  
  <p>I have a class Person, eg</p>
  
  <pre><code>public class Person {
  String name = "";
  }
  </code></pre>
  
  <p>Now, I would like to introspect this class instance &amp; figure out what Class is name declared as.</p>
  
  <p>So, name = String or java.lang.String</p>
  
  <p>This is my Code:</p>
  
  <p>'this' is an instance of Person.</p>
  
  <pre><code>try {
      String className = this.getClass().getName();
          Class cls = Class.forName(className);
          Field fieldlist[] = cls.getDeclaredFields();
          for (int i = 0; i &lt; fieldlist.length; i++) {
             Field fld = fieldlist[i];
             int mod = fld.getModifiers();
             System.out.println("1. " + fld.toGenericString());
             System.out.println("2. " + fld.getName());
             System.out.println("3. " + fld.getGenericType() + "]");
  
  
  
             Object oj = fld.getType();
  
             // Says that 4: class java.lang.String
  
             System.out.println("4: " + oj.toString());
             Class c1 = oj.getClass();
  
             // Should throw Exception
             String stype = c1.getDeclaringClass().toString();
             System.out.println("5. " + stype);
  
  
          }
        }
        catch (Throwable e) {
           System.err.println(e);
        }
  </code></pre>
  
  <p>I managed to get to a part that states:</p>
  
  <p>class java.lang.String</p>
  
  <p>but I need it to be "java.lang.String"</p>
  
  <p>Any ideas?</p>