• Post Reply Bookmark Topic Watch Topic
  • New Topic

interface question  RSS feed

 
Abigail Decan
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


i don't understand the parameter of the method isLargerThan.
what does it mean to pass a "Relatable" object into the method?
what is an object of an interface??
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means that you can pass in an object of any class that implements interface Relatable.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in fact, it's kind of the point of interfaces. You can use ANY class that implements that type. This may not seem like it has much use right now...but say in a year someone comes up with some brand new class (this happens all the time when you license software from third parties) that has better performance than what you are currently using. You can drop that new code in and not touch this code at all, as long as the new class implements your interface.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!