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
  • 1,007
  • 1
  • 10
  • 15

2 Answers2

6

It is called ternary operator.

moonwave99
  • 21,957
  • 3
  • 43
  • 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,208
  • 5
  • 38
  • 63