Java conditional operator ?: result type
- by Wangnick
I'm a bit puzzled about the conditional operator. Consider the following two lines:
Float f1 = false? 1.0f: null;
Float f2 = false? 1.0f: false? 1.0f: null;
Why does f1 become null and the second statement throws a NullPointerException?
Langspec-3.0 para 15.25 sais:
Otherwise, the second and third operands are of types S1 and S2…