Dear Java guru 's!
Can you, please, explain me, why String concatenation does not work properly in Java when concatenating 2 results of ternary operators?
Example:
String str = null;
String x = str != null ? "A" : "B" + str == null ? "C" : "D";
System.out.println(x);
Output is "D", but I expected "BC".
I am suspecting that it works like so because of operators priorities, but I am not sure, about how we exactly we get "D" for case above. What calculation algorithm takes place for this case?