1. Concept
A nested class is a member of its outer class. A non-static nested class (inner class) can access other members of the outer class, even if the member is private of. A static nested class can only access static members of the outer class.
2. Features
(1) Nested category is the only internal category among the four categories, excluding external category objects.
(2) You can define static members.
(3) Can access any external static data members and methods. Constructors are considered static methods and therefore accessible.
3. Example
import java.io.PrintStream; static class OuterClass$Inner { OuterClass$StaticNestedClass(){} void getData(){ System.out.println((new StringBuilder()).append("data is ") .append(OuterClass.data).toString()); } }
1. Simple. As long as you understand the basic concepts, you can write programs suitable for various applications. Applications in this situation;
2. Object-oriented;
3. Distribution, Java is a network-oriented language;
4. Robustness, java provides automatic Garbage collection is used for memory management to prevent programmers from making errors when managing memory;
5. Security, Java used in network and distributed environments must prevent virus intrusion;
6. Architecture neutrality, as long as the Java runtime system is installed, it can run on any processor;
7. Portability, Java can be easily transplanted to different machines on the network;
8. Interpretation and execution. The Java interpreter directly interprets and executes the Java bytecode.
The above is the detailed content of What are the characteristics of nested classes in java. For more information, please follow other related articles on the PHP Chinese website!