Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Interface Access Modifier Issue  RSS feed

 
Brandon Tom
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone explain this to me?



This code doesn't compile because the releaseNutrient () method implemented in HamSandwich isn't public. I thought you could have the access be the same or less restrictive, and they seem to be the same. What's going on here? What are the general rules about this sort of thing?
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interface methods are implicitly public (and abstract).
Therefore, you must declare implementations of interface methods as public.

Avoid redundant redudancy by redundantly and explicitly specifying redundant modifiers in a redundant manner, such as public and/or abstract on interface methods.
 
Brandon Tom
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the tip.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!