import java.util.Collection; public class Test { public static void main(String[] args) { Collection c = null; Test s = null; s = (Test) c; } }
In the above code example, I throw the collection object into the Test object. (ignoring the null pointer). The test is not related to the collection at all, but this program will pass all the compile-time checks.
I wonder why this is so. My guess is that interfaces are ignored because they are too complex. They donβt have a common supertype, and each class can implement several interfaces, so the class / interface hierarchy will be too complicated for an efficient search?
Besides, I'm still dumb. Somebody knows?!
source share