title: Java: How to check if a Field is of type java.util.Collection
body: <p>I have a utility method that goes through various classes and recursively retrieves the fields. I want to check if that field is a Collection.
  Here is some sample code:</p>
  
  <pre><code>void myMethod(Class&lt;?&gt; classToCheck)
  
  Field[] fields = classToCheck.getDeclaredFields();
  
  for(Field field:fields)
  {
     // check if field if a Collection&lt;?&gt;
  
  }
  </code></pre>
  
  <p>Thanks in advance for the help.</p>