title: The ? (three way) Operator
body: <p>First of all, apologies for the following question, i am new to java, i have taken the example from a book but it fails to completely explain itself.</p>
  
  <p>I have been reading about the ? operator and how it functions and using the below as an example to learn from:</p>
  
  <pre><code>class Ternary {
      public static void main(String args[]) {
          int i, k;
          i = 10;
          k = i &lt; 0 ? -i : i; // get absolute value of i
          System.out.print("Absolute value of ");
          System.out.println(i + " is " + k);
  
          i = -10
          k = i &lt; 0 ? -i : i; //get absolute value of i
          System.out.print("Absolute value of ");
          System.out.println(i + " is " + k);
      }
  }
  </code></pre>
  
  <p>I understand how the first part gives the result of 10.
  But i cannot follow how the second part gives the result of 10?</p>
  
  <p>Apologies if this is plainly obvious.</p>