Can null
be casted to any type? i.e. will the following code work
public <T> T foo(Object object){
return (T) object;
}
Duck duck = foo(new Duck()); // this works
Duck duck2 = foo(null); // should this work?
Cat cat = foo(null); // should this work?
// if they are both null, should this be true?
boolean equality = duck2.equals(cat);
My question is, is null
'castable to anything'?