title: Java one line if does not work for prints
body: <p>If you write something like:</p>
  
  <pre><code>    boolean condition;
      (...)
      String out = condition ? "true" : "false";
      System.out.println(out);
  </code></pre>
  
  <p>It works. But if you write</p>
  
  <pre><code>    condition ? System.out.println("true") : System.out.println("false");
  </code></pre>
  
  <p>you get a "not a statement" error. The "correct" way is to write (the usage of braces or "to be or not to be in one line" is out of the scope of the question):</p>
  
  <pre><code>    if (condition)
          System.out.println("true");
      else
          System.out.println("false");
  </code></pre>
  
  <p>Why? The one line <code>if</code>s must always return a value?</p>
  
  <p><strong>EDIT:</strong> To everyone pointing out that</p>
  
  <pre><code>    condition ? System.out.println("true") : System.out.println("false");
  </code></pre>
  
  <p>is not a correct syntax, yeah I got that part. I am not asking for solutions (although the</p>
  
  <pre><code>    System.out.println(condition ? "true" : "false");
  </code></pre>
  
  <p>is nice.</p>
  
  <p>@Andrew Tobilko where is that stated? <strong>THAT</strong> is what I'm interested in.</p>
  
  <p><strong>EDIT2</strong>: The accepted answer provides exactly what I wanted. Thanks</p>