The compiler isn't executing two returns. The code in the video is:
try {
return (String) o;
} catch (ClassCastException e) {
typeWarning(key, o, "String", e);
return null;
}
The code is trying to cast the Object o
to a String, but the cast fails and throws a ClassCastException
, which is caught by the next line. Inside that catch block, it then returns null
because it can't do the original String conversion.