Next page | Contents page |

Access modifiers

Now we know all about packages we can complete the story about access modifiers.

Modifiers for classes, interfaces, methods & fields which determine visibility:

Notice that the default case is more restricted than the protected case.

There is no keyword for the default case. I think this is a mistake in the design of the language because if there is no access modifier you cannot be certain whether the programmer forgot to put one or he really did mean package visibility only. Often the latter really is the intention (particularly useful for unit testing, which we will cover later) but someone reading the code might think it is a mistake. Be careful.

Next page | Contents page |