<<< Multiple classes in one java file | Index | Local classes >>> |
An example of two classes nested within another class:
public class OuterClassName { // can contain instance variables and methods // can contain static variables and methods class InnerClassName { // can contain instance variables and methods // can't contain static variables or methods // can access all variables and methods of // OuterClass }//class InnerClassName static class StaticInnerClassName { // can contain instance variables and methods // can contain static variables and methods // can access static variables and methods of // OuterClass // can't access instance variables or methods of // OuterClass }//class StaticInnerClassName }//class OuterClassName
The class files generated for the nested classes are:
OuterClassName.class OuterClassName$InnerClassName.class OuterClassName$StaticInnerClassName.class
<<< Multiple classes in one java file | Index | Local classes >>> |