null « cast « Java Data Type Q&A

1. Why null cast?

I saw this piece of code somewhere and wondered: when and why would somebody do the following:

doSomething( (MyClass) null );
Have you ever done this? Could you please share your experience?

2. Why cast null to Object?

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

3. Casting a null object...

Interesting question though.... Was busy working with JDialog today and an interesting scenario presented itself. What if you have a constructor that takes an object as an argument (as a lot of, if not most, do) but you'd like not to pass it anything such as the parent frame of a JDialog. But it has constructors which would be ambiguous if ...

4. null variable casting