Originally posted by Kevin Lam:
I am stupid, but can I ask what's wrong with it?
Is it because null and true aren't compatible? would it compile if null + "true"?
Kev
1. No, Kevin, you are not stupid - stupid people do not ask questions or have doubts.
2. As Steve said above, + is only overloaded for String objects. If one of the operands of + is a String, then the operator attempts to convert the other operand to a String. null get converted to the String "null".
The best thing is to write code and compile and run it, at the same time ask questions as you go.
For instance I am wondering about what happens in the case of (String)null + true. Will that cast work? Will it produce "nulltrue"? I do not know, so let's try it...
Yes it does! But null + (String)true does not. Why not? Leave that to you...
[ October 28, 2005: Message edited by: Barry Gaunt ]