Marcel Reutegger wrote:
IvanLatysh wrote:
And a call:
setAge((Integer)null) - where I pass null reference as Integer.

this is not correct. just because you can cast null to any reference type does not mean that the type of your so called 'null value' is an Integer.
Yes it is, and it is so per spec.

The cast is only there to indicate the compiler which method to chose if it is overloaded. e.g. you might have setAge(Double age) and setAge(Integer age). if there's just the latter signature the cast is redundant and unnecessary.
[Java Language Specification : Third Edition : 5.5 Casting Conversion]
Casting conversion is applied to the operand of a cast operator (ยง15.16): the type of the operand expression must be converted to the type explicitly named by the cast operator.
[/Java Language Specification : Third Edition : 5.5 Casting Conversion]

P.S. I been sent to read Java spec, and I don't mind to refresh my knowledge. But I can see that it is not me, who should read the Java Language spec.

--
Ivan Latysh
[EMAIL PROTECTED]

Reply via email to