Inner class
(). The role of the inner class.
1. Implements the hiding of the inner class.
2. Multiple inheritance was achieved.
3. The inner class has access to properties and methods owned by all external classes.
4. Avoid modifying the interface when the same name method appears.
I. member INNER class.
1. If we want to access the inner class, we must have an instance of the outer class! Access can only be accessed through an external class.
2. The member inner class can have private,protected access.
Two. local inner class.
1. Must be in a method or scope.
2. Rights are limited to the internal role of the method body.
3. When the formal parameter of our method needs to be used in the inner class! Then this parameter must be final decorated.
Three. Static Inner class:
1. Do not rely on external classes.
2. Add the modifier static to the inner class.
3. Cannot access external class non-static methods and properties.
Four. Anonymous inner class:
1. No name.
2. Requires that all anonymous inner classes must implement an excuse or inherit a class.
3. When the formal parameter of our method needs to be used in the inner class! Then this formal parameter is more than the vegetarian final modification;
Java Public lesson -03-inner class