Game Development Reference
In-Depth Information
is instance specific, meaning that objects (instances) created via that class can be differ-
ent from each other (an object is a unique instance of a class), whereas a static (fixed)
nested class will only have one version, which does not change. For instance, a private
inner class can only be used by a parent class that contains it. The SplashScreen
inner class coded as a private class would look something like this:
public class InvinciBagel extends Application {
private class SplashScreen {
// The Java code that creates and displays your
splashscreen is in here
}
}
Because this class is declared as private, it is for your own application usage (the
containing class's usage, specifically). Thus, this would not be a utility or constant
class for use by other classes, applications, or developers. You can also declare your in-
ner class without using the private access modifier keyword , which would look like
the following Java programming construct:
public class InvinciBagel extends Application {
class SplashScreen {
// The Java code that creates and displays your
splashscreen is in here
}
}
This level of access control is called package or package private and is the de-
fault level of access control applied to any class, interface, method, or data field that is
declared without using one of the other Java access control modifier keywords (public,
protected, private). This type of inner class can be accessed not only by the top-level,
or containing, class, but also by any other class member of the package that contains
that class. This is because the containing class is declared public, and the inner class is
declared package private. If you want an inner class to be available outside the pack-
age, you declare it to be public , using the following Java code structure:
public class InvinciBagel extends Application {
public class SplashScreen {
// The Java code that creates and displays your
splashscreen is in here
Search WWH ::




Custom Search