1

Possible Duplicate:
What is the Java ?: operator called and what does it do?

What is this type of code statement called? I've seen it in Java and C++ before, but I can't remember what it is called. int someVariable = (true) ? 1 : 0;

Community
  • 1
  • 1
Emrys90
  • 987
  • 1
  • 9
  • 14

2 Answers2

6

It is called ternary operator.

moonwave99
  • 20,750
  • 2
  • 41
  • 64
0

Its ternary operator to avoid line of codes for simple condition checking

int biggerNumber = a > b ? a : b;

even more

int bigNumber = a > b ? (a > c ? a : c) : b > c ? b : c ;

vels4j
  • 11,026
  • 5
  • 39
  • 57