English subtitles

← What If We Forget to Check the Type - Intro to Java Programming

Get Embed Code
6 Languages

Showing Revision 5 created 09/10/2017 by Dejan Trajkovic.

  1. Casting with instance of checks is something you will occasionally need to use
  2. when programming in Java, but it's best to avoid it in general. Let's explore
  3. why. Here's the code for Scene.java that you wrote before. What if we had
  4. accidentally forgotten to do this check and I just gone through all of the
  5. elements and tried to move them. What will happen if I run the program now?
  6. Feel free to try this yourself in BlueJ. Will the program run the same way?
  7. Will the houses move even though they should be stationary? Will there be a
  8. compile time error because drawables can't be cast to type movable? Or will
  9. there be a run time error? Because some drawables cannot be cast to type
  10. moveable. Like I said, if you're not sure feel free to try it out.