title: Getting first parent's fields via reflection
body: <p>I'm trying to get the fields and values of my object's first parent. My current code is this:</p>
  
  <pre><code>Class&lt;? extends Object&gt; cls = obj.getClass();
  Field[] fields = cls.getDeclaredFields();
  for ( Field field : fields )
  {
      String fieldName = field.getName();
      String fieldValue = field.get(obj);
  }
  </code></pre>
  
  <p>My class structure is similar to this:</p>
  
  <pre><code>class A
  {
      int x;
  }
  
  class B extends A
  {
      int y;
  }
  
  class C extends B
  {
      int z;
  }
  </code></pre>
  
  <p>Now, I pass a C object to the method and I want to get all fields from C and B, but not from A. Is there a way to do this (using reflection, I don't want to implement other methods)?</p>