title: why does the catch block give an error with variable not initialized in Java
body: <p>This is the code that I've written.</p>
  
  <pre><code>int num;
  try {
      num=100;
      DoSomething();
      System.out.println(num);
  } catch(Exception e) {
      DoSomething1();
  } finally{
      DoSomething2();
  }
  System.out.println(num); // Error Line
  </code></pre>
  
  <p>I get an error 'The local variable num may not have been initialized' on the error line that I've mentioned. On removing the catch block the error goes away. What is wrong here? Am I doing something incorrect?</p>