The java code K.I.L.E.R posted, and the one you claimed was in ArrayList (can’t find it personally) is not valid java code in the sense that it would always throw a runtime exception and fail.
“(String)new Object();” will compile, but it will always fail at runtime, just like “(String[])new Object[];” will.
And I don’t think anyone would say that “(String)new Object();” is valid java code.