title: Return Type Boolean in Java
body: <p>I have a question on <code>boolean</code> return types.
  Check the following code:</p>
  
  <h1>Code Sample 1</h1>
  
  <pre><code>boolean flag = sampleMethod();
  
  public boolean samplemethod(){
      return false;
  }
  </code></pre>
  
  <h1>Code Sample 2</h1>
  
  <pre><code>sampleMethod();
  
  public boolean samplemethod(){
      return false; 
  }
  </code></pre>
  
  <p>In the above two examples, the code compiles properly without any compile time or run time exceptions.
  My doubt is, Java doesn't make it mandatory for the <code>boolean</code> return type to be assigned in the calling program, where for the other data types the program does not work.
  Can you please explain the reason for this to me?</p>