title: Java: how to "instanceof argument"
body: <p>I have tried:</p>
  
  <pre><code>package ro.ex;    
  
  import java.io.IOException;
  import java.lang.reflect.Type;
  
  class Ex {
      public boolean isIns(Object o, Class t) {
          o instanceof t;
      }
      public static void main(String[] args) throws IOException {}
  }
  </code></pre>
  
  <p>above code will raise unknown class "t"</p>
  
  <p><strong>My question is:</strong> How to pass above code.</p>
  
  <p><strong>update:</strong></p>
  
  <p>following code can't pass intellij idea syntax checker</p>
  
  <pre><code>public boolean isIns(Object o, Class&lt;?&gt; t) {
      return o instanceof t;
  }
  </code></pre>
  
  <p>so the right code in idea is:</p>
  
  <pre><code>public boolean isIns(Object o, Class&lt;?&gt; t) {
      return t.isAssignableFrom(o.getClass());
  }
  </code></pre>
  
  <p>the more simple way is:</p>
  
  <pre><code>package ro.ex;
  
  import java.io.IOException;
  import java.lang.reflect.Type;
  
  class Ex {
      public boolean isIns(Object o, Class t) {
          return t.isInstance(o);
      }
  
      public static void main(String[] args) throws IOException {
          Object r = new Ex().isIns("", String.class);
          System.out.println(r + "\t\t" + new Exception().getStackTrace()[0].getFileName() + ":" + new Exception().getStackTrace()[0].getLineNumber());
      }
  }
  </code></pre>