When using the triple operator
flag ? type1 : type2
Type1 and type2 must be of the same type during conversion. It implements type1 first, and then type2.
Now look at your cases
final Integer b = false ? 0 : a;
As it type1is 0, and it takes as a primitive, and since atrying to transform it as primitive. Hence the null pointer.
where is the same difficult test5
final Integer b = false ? a : 0;
a Integer 0, LHS.