Inner Classes
Classes, as we have seen so far, cannot be hidden to other parts of the program. In code terms, they cannot be made private. To offer this kind of security mechanism, Java developed so-called inner classes. This type of class is declared nested within other classes. A quick example of this follows:
Example16.java
1 class Container { 2 // inner class 3 private class Continent { 4 public void print() { 5 System.out.println("This is an inner class"); 6 } 7 } 8 9 // method to give access to the private inner class' method 10 void printContinent() { 11 &...