title: Java: Check if a generic is an int
body: <pre><code>public class Hashing&lt;Key, Elem&gt;
  </code></pre>
  
  <p>I want to check if Key is an int, so I place this lines in the constructor:</p>
  
  <pre><code>Key key = null;
  if (!(key instanceof Integer)) {
      throw new TypeOfKeyStillNotSupportedException();
  }
  </code></pre>
  
  <p>However, I create one this way:</p>
  
  <pre><code>tHash = new Hashing&lt;Integer, Movie&gt;(max);
  </code></pre>
  
  <p>And the damn TypeOfKeyStillNotSupportedException() pops. Why is this happening and how can I do it properly?</p>
  
  <p>Thanks in advance.</p>
  
  <p>Edit: Already found that the problem is with key being assigned null. The question is now: How to do the check?</p>