title: declaration of variable inside a loop vs multiple declarations of the same variable name
body: <p>the following code gives an error, because the variable m was defined twice.</p>
  
  <pre><code>class one {
     public static void main(String args[]) {
       int m=10;
       int m=10;
     }
   }
  </code></pre>
  
  <p>but when the declaration is done inside a loop, it is OK, even though <code>m</code> is still being defined twice.</p>
  
  <pre><code> class one {
     public static void main(String args[]) {
       for(int i=1;i&lt;=2;i++) {
         int m=10;
       }
     }
   }
  </code></pre>
  
  <p>and the compiler does not give back an error message.<br>
  can you explain the differences between the two, and how come sometimes i can declare the same variable twice inside the same method, and sometimes not?</p>