I noticed that a java.util.Map is castable to java.io.Serializable. But java.util.Map and java.io.Serializable are not in relation. Why can I cast a class to another one even if they are not in any relation? It is neither upcasting nor downcasting...
Well, in general, I have two interfaces I1, I2, that are NOT in relation to each other. Then, there is a class C1 that implements both I1 and I2 and a class C2 that implements only I1. It seems to be legal to cast a reference for I1 to the type I2. I mean:
(In our case I1=java.util.Map, I2=java.io.Serializable, C1=java.util.HashMap, C2=java.util.jar.Attributes)
But this situation, in general, is NOT valid. In fact, if you cast a java.util.Map to a java.util.List, it is not legal. But the relationship between java.util.Map and java.util.List is the same as java.util.Map and java.io.Serializable, except for the fact that today nobody has yet created a class that both implements java.util.Map and java.util.List.