System.out.println("5" + null); System.out.println(5 + null); I get 5null for both the statements. I cannot even compile when I use *, /, % or - operators in the second statement. I understand that when one of the operands is a String in a binary + expression, the other operand is made a String object and a String concatenation happens. But with null...!!! Please explain [ July 22, 2002: Message edited by: Madan, Gopal ]
Now only reference values need to be considered. If the reference is null, it is converted to the string "null" (four ASCII characters n, u, l, l). Otherwise, the conversion is performed as if by an invocation of the toString method of the referenced object with no arguments; but if the result of invoking the toString method is null, then the string "null" is used instead.