1

In Java, why is a protected top-level class not allowed? I've heard answers along the lines of, "It doesn't make sense," but why?

  • possible duplicate of [Why can't you have a protected abstract class in Java?](http://stackoverflow.com/questions/8160019/why-cant-you-have-a-protected-abstract-class-in-java) – Rick Hanlon II Sep 26 '13 at 00:47
  • check out [package-private](http://stackoverflow.com/questions/6470556/pros-and-cons-of-package-private-classes-in-java), I was looking for a protected top level class for modularity – Clocker Dec 02 '16 at 06:46

1 Answers1

1

Because you could never access it, so it'd be pointless.

protected is about giving subclasses of the containing type access to a member, if there's no containing type, what would it mean? <-- hence pointless.

Alec Teal
  • 5,770
  • 3
  • 23
  • 50