title: instanceof in Java - why doesn't this compile?
body: <pre><code>class A {
  
      public static void main(String...args) {
          Integer var = 10; 
  
          if(var instanceof Character)  // Line1
              System.out.println("var is a Character");
      }
  }
  </code></pre>
  
  <p>I know <em>Line 1</em> will not compile because the compiler has found that <code>var</code> is not a <code>Character</code>.</p>
  
  <p>What I fail to understand is why the compiler throws an error instead of returning <code>false</code> or <code>true</code>.</p>
  
  <p>If the compiler returns <code>false</code> or <code>true</code> (i.e treating the <code>instanceof</code> operation like a regular if-based validation), then it be much more useful.. would it not?</p>
  
  <p>Or am I missing something obvious?</p>