• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Allowable Interface modifier types

 
Chris Allen
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In one of the Java books I am reading/experimenting with, it states that "interfaces can have acces modifiers of pulic or blank, similar to classes." My question is why can't that list include protected? An interface can be extended which in my mind, means that protected would be valid as well if you want to control what classes/other interfaces have access to it. Am I reading into the statement too much that protected is not allowed or is it just that it was not mentioned in the statement specifically?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chris Allen:
My question is why can't that list include protected?


Top-level classes can't be protected, only methods can be, and interfaces are no different. All the methods in an interface are always implicitly public; the interface itself can be public or not, just like a class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic