title: retrieving instance from Class object java
body: <p>I understand that the following can be done . </p>
  
  <pre><code>User user = new User();
  user.setUsername("a");
  user.setPassword("abc");
  
   Class c = user.getClass();
  </code></pre>
  
  <p>However I have a situation in which I have to extract the instance information from the variable "c"</p>
  
  <p>Is it even possible ? . We do have a c.newInstance() method but that would create a new instance of the object User. I need to access the existing instance of the User , which was responsible for creating the "c" variable in the first place . </p>
  
  <p>Thanks</p>
  
  <p>-----------EDIT-----------
  Looking at the comments I understood that my concept of getClass was flawed . What I want to achieve is that I need a method which would iterate over an object's getters . So what would be the signature of such ?</p>
  
  <p>I was thinking on the lines of </p>
  
  <pre><code>public static &lt;T&gt; List&lt;NameValuePair&gt; entityConvert1(Class&lt;T&gt; entity)
  </code></pre>
  
  <p>however as per all the comments , I understand passing the Class wont send in any instance specific information in the method . </p>
  
  <p>I need a torch here . </p>