0

Hi I don't know what this line of code does

res = (actual.left != null) ? actual.left:actual.right;

what does the ? do and the : in actual.left:actual.right

thanks

pengj
  • 1
  • 3
  • 2
    It's a [ternary operator](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/op2.html), shorthand for it-then-else – copeg May 16 '15 at 20:55
  • It's a conditional expression. The expression before the ? is evaluated as a boolean expression. If true, do what immediately follows the ? otherwise do what follows the : – swingMan May 16 '15 at 22:12

0 Answers0