Game Development Reference
In-Depth Information
strictive level of access control in Java. A variable declared private can be accessed
outside the class if a public method that accesses a private variable from inside the
class, called a public .get() method call, is declared public and thus provides a pathway
(or doorway) through that public method to the data in the private variable or constant.
Java's Package Private Modifier: Variables, Methods,
and Classes in Your Package
If no Java access control modifier keyword is declared, then a default access control
level, which is also referred to as the package private access control level, will be ap-
plied to that Java construct (class, method, data field, or interface). This means that
these Java constructs are visible, or available, to any other Java class inside the Java
package that contains them. This package private level of access control is the easiest
to use with your methods, constructors, constants, and variables, as it is applied simply
by not explicitly declaring an access control modifier keyword.
You will use this default access control level quite a bit for your own Java applica-
tions (game) programming, as usually you are creating your own application in your
own package for your users to use in its compiled executable state. If you were devel-
oping game engines for other game developers to use, however, you would use more of
the access control modifier keywords I have discussed in this section to control how
others would use your code.
Nonaccess Control Modifiers: final, static, abstract,
volatile, synchronized
The Java modifier keywords that do not specifically provide access control features to
your Java constructs are termed nonaccess control modifier keywords . These include
the often used final , static , and abstract modifier keywords as well as the not so often
used synchronized and volatile modifier keywords, which are employed for more ad-
vanced thread control and which I will not be covering in this beginner-level program-
ming title, except to describe what they mean and do, in case you encounter them in
your Java universe travels.
I will present these concepts in the order of their complexity, that is, from the easi-
est for beginners to wrap their mind around to the most difficult for beginning OOP de-
velopers to wrap their mind around. OOP is like surfing, in that it seems very difficult
until you have practiced doing it a number of times, and then suddenly you just get it!
Search WWH ::




Custom Search