I found a spot in some code I'm working on where null
is cast to Object
as it is passed to a method.
Why would this be done?
I am aware of this question which deals with overloaded methods, and using the cast to determine which version of the method to call.
But if the cast were not performed, wouldn't an overloaded method with a parameter typed as Object
be chosen over any other matching version of the method if the method is called with a null argument? So what else does the cast accomplish?