|
A) Anonymous class (different from anonymous objects)
There is no clear class definition format, which refers to the combination of class definition and Class Object creation.
An anonymous class is a unique object and defines an anonymous class when an interface is generated.
B) Static class
Static classes exist in a class as static members of the class,
Class outerclass
{
Static class innerclass
{
.....
}
}
It can be viewed as a static member of the class. Static members can directly use it without creating an outerclass object, that is, they can directly create an innerclass object without creating an outerclass object.
Inside outerclass:
Innerclass OBJ = new innerclass ();
Outside outerclass:
Outerclass. innerclass OBJ = new outerclass. innerclass ();
C) member class
A member class is a common member variable in a class. Defining a member class is no different from defining a general class.
Class outerclass
{
Class innerclass
{
.....
}
}
Like using common member variables, an innerclass object can be created only after an outerclass object is created.
Outerclass objout = new outerclass ();
Objout. innerclass objin = new objout. innerclass ();
D) Local class
The local class is defined inside the method like the local variable. The local class can only be used inside the method, and disappears after the method is executed.
|