7.11. Modifiers in Declarations

We've used a variety of class, method, and instance variable modifiers in this chapter: public, private, protected, and static. These were relatively obvious from context or from the brief explanation provided when they were used, but it is worth reviewing all the possible modifiers and explicitly stating their purpose.

Visibility Modifiers

These modifiers designate the other classes that are allowed to see the data inside an object you write. Table 7.1 summarizes them, with more details given below. If you are not familiar with object-oriented programming already, just look at public and private and forget the other options for now. For people with a C++ background, consider classes within the same package to ...

Get Core Web Programming, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.