If I try to cast a String to a java.util.Date, the Java compiler catches the error. So why doesn't the compiler flag the following as an error?
List<String> strList = new ArrayList<>();
Date d = (Date) strList;
Of course, the JVM throws a ClassCastException at runtime, but the compiler doesn't flag it.
The behavior is the same with javac 1.8.0_212 and 11.0.2.