Return to Video

Drawable Equals New Drawable - Intro to Java Programming

  • 0:01 - 0:05
    The answer is, you can't construct an interface type. We know this can't be the
  • 0:05 - 0:08
    answer because we have assigned objects of certain classes to variables of
  • 0:08 - 0:13
    interface types. In the example before this, you saw code that created new dogs
  • 0:13 - 0:16
    and then put them in drawable variable or added them to lists of drawable
  • 0:16 - 0:22
    items. So this statement is false. This statement is true, but doesn't apply in
  • 0:22 - 0:28
    this case. I can only put an object into a variable with an interface type if
  • 0:28 - 0:34
    the object is of a class that implements the interface. Like in this case. But
  • 0:34 - 0:38
    if the dog class didn't implement the drawable interface, I wouldn't be able to
  • 0:38 - 0:43
    do this. If you're not quite sure why you can't construct an interface type,
  • 0:43 - 0:47
    let's look at the code. This is the code for a dog. It has all of the
  • 0:47 - 0:51
    information on how to move and how to draw. The drawable interface has almost
  • 0:51 - 0:55
    no information at all. If you tried to make a new drawable, it would know that
  • 0:55 - 0:59
    it should know how to draw. But wouldn't know how to draw. That's why Java
  • 0:59 - 1:03
    won't let you construct a drawable.
Title:
Drawable Equals New Drawable - Intro to Java Programming
Description:

more » « less
Video Language:
English
Team:
Udacity
Project:
cs046: Intro to Programming
Duration:
01:03

English subtitles

Revisions Compare revisions