title: Can method return more than one type
body: <p>I am new to Java and trying to understand the below code:</p>
  
  <pre><code>int someMethod() {
      return (true ? null : 0);
  }
  </code></pre>
  
  <p>The method's return type is <code>int</code>, but it can return both <code>null</code> and <code>int</code>, is this correct behavior in Java? Can a Java method return more than one type? This may sound silly for those who are experienced, but I have just took my first step in Java.</p>