title: error on if condition java
body: <pre><code>public class SomeClass{
  
      public static void main (String[] args){
          if(true) int a = 0;// this is being considered as an error 
          if(true){
              int b =0;
          }//this works pretty fine
      }
  }//end class
  </code></pre>
  
  <p>In the above class first if statement is showing an compilation error </p>
  
  <pre><code>Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
      Syntax error on token "int", delete this token
      a cannot be resolved to a variable
  </code></pre>
  
  <p>However second if statement works fine. I just cannot figure it out myself. I know it is of no use declaring a variable in a single statement <code>if</code>. How those two statements are different can some one please explain me. Excuse me if the question is really simple.</p>