title: how to read object attribute dynamically in java?
body: <p>Is there any way to read and print the object attribute dynamically(Java) ? for example if I have following object </p>
  
  <pre><code>public class A{
    int age ;
    String name;
    float income;
  
  }
  
  public class B{
   int age;
   String name;
  }
  
  public class mainA{
     A obj1 = new A();
     method(A);
     method(B); 
  }
  
  the output should be like
  
  While running method(A):
  Attribute of Object are age,name,income;
  While executing method(B):
  Attribute of Objects are age,name;
  </code></pre>
  
  <p>My question is I can pass various object in method(), is there any way I can access the attribute of the differnt object in general.</p>