سؤال

In class of system android sdk Bandle.class happened magic. I can't explain why compiler execute two returns! See on attached video. Anybody can explain what is trouble ? https://www.youtube.com/watch?v=ObOZ60OEse4&feature=youtu.be Second case: https://www.youtube.com/watch?v=WB4k48MCST0&feature=youtu.be

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top