java - Strange Null pointer exception case: ternary conditional operator not working with string concatenation -
stringbuffer sb = null; // There is more argument that conditionally assigns value for string buffer / / print value = zero System.out.println ("value =" + SB); // throws NullPointerException System.out.println ("value =" + sb! = Null? Sb.stream (): "tap"); The fix for this problem is being included in the field as a Ternary Operator:
// Works Fix System. Out.printline ("value =" + (Sb! = Null? Sb.toString (): "null")); How is this possible?
A + in ! = more than
Then you "(value =" + SB ")! Empty = null already.
Comments
Post a Comment