title: variable cannot be resolved ( variable used in if else statement)
body: <p>I m just learning coding so I got this problem " k cannot be resolved"</p>
  
  <p>I have tried introducing variables before if the operator by: </p>
  
  <pre><code>double a = 2.1223;
  int b = (int) a;
  
  if(a-b &gt; 0.5) { 
     int k = b + 1;
  }
  
  else { 
     int k = (int)b ;
  }
  
  System.out.println(k); // k cannot be resolved.why??
  </code></pre>
  
  <p>I expected output to be 2 </p>
  
  <p>instead got k cannot be resolved</p>