Checking Java Collection Generic Type for an Empty Collection
<p>I want to implement the following function:</p>

<pre><code>public boolean checkType(Vector&lt;?&gt; vec)
{
  // return true if its Vector&lt;Integer&gt; and false otherwise
}
</code></pre>

<p>How can I check the vector elements type ? 
<strong>Note that</strong> the vector might be empty thus I can't check if the first element is "instanceof" Integer or String ...</p>

<p><em>EDIT:</em></p>

<p>Well, I had something in mind I don't know if it will work or not</p>

<p>Can I implement the checkType function as following:</p>

<pre><code>public &lt;T&gt; boolean checkType(Vector&lt;T&gt; vec)
{
  // return true if T is Integer and false otherwise
}
</code></pre>

<p>is it possible to check if T is Integer ?!</p>

<p>Thanks in Advance</p>
