0

as i'm browsing through some java exercises in Programmr, i found this line:

   String result = ((num & mask) == 0) ? "even" : "odd"; 

It's a line from a program that determines if a number is odd or even. I want to know what does this line exactly means especially the "?" that looks like a rogex meta-character but is not inside the "".

  • 1
    It's the conditional `? :` operator. – Jon Skeet Jul 12 '16 at 07:16
  • 4
    The `?` and `:` together are the [ternary operator](https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html). (Although I note that the answer in the duplicate points out that the spec calls this the ["conditional operator"](http://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.25)). – Andy Turner Jul 12 '16 at 07:16

0 Answers0