title: Error: variable might not have been initialised
body: <p>I am doing a book exercise regarding the Ackermann function.</p>
  
  <p>I have one question though. If I declare result but do not initialise it, the compiler complains that "variable result might not have been initialised". </p>
  
  <pre><code>int result;
  </code></pre>
  
  <p>When I set it to default to 0, it does not complain.</p>
  
  <pre><code>int result = 0;
  </code></pre>
  
  <p>I thought that when one declares a variable with type int it defaults to 0 automatically.</p>
  
  <p>Here's the complete code:</p>
  
  <pre><code>public class Ackermann {
     public static int ack(int m, int n) {
       int result = 0;
       //int result;
       if (m == 0)
          result = n + 1;
       else if(m &gt; 0 &amp;&amp; n == 0)
          result = ack(m-1, 1); 
       else if(m &gt; 0 &amp;&amp; n &gt; 0)
          result = ack(m-1, ack(m, n-1));
       return result;
     }   
  
     public static void main(String[] args) {
        System.out.println(ack(3, 3));  
     }   
  
  }
  </code></pre>