title: Nesting Five Conditional Operators
body: <p>Is it possible to nest more than 5 'Conditional Operators' in Java.  I ask because it seems that I cause a compiler exception when I try to compile this code:</p>
  
  <pre><code>public Object getValue() {
          return
              number  != null ? number    :
              string  != null ? string    :
              bool    != null ? bool      :
              date    != null ? date      :
              list    != null ? list      :
              null;
  }
  </code></pre>
  
  <p>I have narrowed it down to this code because if I comment out the last line it seems to compile fine.</p>
  
  <pre><code>public Object getValue() {
          return
              number  != null ? number    :
              string  != null ? string    :
              bool    != null ? bool      :
              date    != null ? date      :
  //        list    != null ? list      :
              null;
  }
  </code></pre>
  
  <p>Does anybody else know if this is a limitation of the java compiler or am I jumping to false conclusions, it would be great if someone else could try to reproduce this.  If anybody is interested I have reproduced and posted the <a href="https://gist.github.com/919284" rel="nofollow noreferrer" title="Github Gist">Stack Trace</a> from the compiler here <a href="https://gist.github.com/919284" rel="nofollow noreferrer">https://gist.github.com/919284</a>. </p>
  
  <p>Note that it is very likely a bug in the compiler not my code, as the output said "Please File a Bug at Java Developer Connect site" (or something similar).  I am asking here because I am not sure what that bug report would contain.</p>
  
  <hr>
  
  <p>EDIT:
  Chris L has reproduced this, see his <a href="https://stackoverflow.com/questions/5662090/nesting-five-conditional-operators/5664277#5664277">answer</a></p>