title: How to get a returned List of Objects object type from a Java method?
body: <p>I have a getter method in a Class that returns a list of objects. It looks something like this:</p>
  
  <pre><code>public List &lt;cars&gt; getCars() {
  
  // some code here
  
  }
  </code></pre>
  
  <p>The class contains some other getters as well as this one. In another Class, I want to get all the getter methods contained in the first class and display the name of the methods and the returned data types.</p>
  
  <p>I'm able to get the name of the above method (getCars) and it's returned data type (List). However, I can't seem to get "Cars" as the type of object that the list contains. The best I can get is "ObjectType". Is there a way of getting "Cars" to be displayed? I've read about Type Erasure and how Generics are removed in the bytecode as it's only used for the benefit of the Java compiler. Is my problem related to Type Erasure?</p>
  
  <p>Is it possible to get the word "Cars" displayed? When I read about Type Erasure there seems to be a way to get Generics from a List but the examples I've seen are for String and Integer and not objects. </p>
  
  <p><a href="https://stackoverflow.com/questions/1942644/get-generic-type-of-java-util-list">Get generic type of java.util.List</a></p>
  
  <p>Thanks</p>