title: How to iterate through all properties of a Java bean
body: <p>Below is my bean structure. Employee.java is the parent bean. I would like to iterate through all the properties till the Zip.java and manipulate the values.</p>
  
  <p>I tried to iterate this using reflection, but getDeclaredFields() will give the fields of the top level object only. How to iterate over deeper objects.</p>
  
  <p>Could someone let me know how to do this in java. </p>
  
  <p><strong>Employee.java</strong></p>
  
  <pre><code>private String id;
  private String name;
  private int age;
  private Address addr;
  private Contact cont;
  </code></pre>
  
  <p><strong>Address.java</strong></p>
  
  <pre><code>private String addr1;
  private String addr2;
  private String city;
  private Zip zip;
  </code></pre>
  
  <p><strong>Contact.java</strong></p>
  
  <pre><code>private String phone;
  private String email;
  </code></pre>
  
  <p><strong>Zip.java</strong></p>
  
  <pre><code>private String zipCd;
  private String zipExt;
  </code></pre>