2

I have been reading a book called "Head First Design Patterns-A brain friendly guide" by Eric Freeman & Elizabeth Robson. All of their examples are in Java.

On page 15, what they have done is:

  • In a duck class, two variables of interface type are declared. Please see the image.

enter image description here

As a newbie in Java, I have always thought the way to utilize interface is via "implement", but this example surely got me thinking.

May I ask if it is a common practice to use interface this way? I could have completely missed something here.

Thank you

Andrew Tobilko
  • 48,120
  • 14
  • 91
  • 142

0 Answers0