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

Accessor modifier  RSS feed

 
Manish Vyas
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are four accessor modifier named- public, protected, defualt(unnamed) and private. I am a bit confused about the difference between default and protected accessor modifier. Will someone elaborate?
 
Vagner Freitas
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

A method without accessor modifier (default) can be visible for all other classes in same package.
A protected method can be visible for all other classes in same package, and all sub-classes even if the sub-classes are in another package.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!