Internal class
Class within the class
1. Solve multiple inheritance
2. resolves conflicts between methods during inheritance and interface implementation
3. Data Hiding
Only internal classes can have four types of access Modifiers
When the internal class is private, an external class provides methods to access the internal class.
Regular internal class
1. Static attributes and methods are not allowed
2. Internal classes can use all attributes and methods of external classes.
3. External classes cannot directly use internal class attributes and methods. They must be instantiated before use.
If the attributes and methods of the internal class mask the external class methods
External class. this. Attributes/methods
To call the attributes and methods of an external class.
Static internal class
It can contain static methods and attributes.
No need to instantiate external classes
StaticOutter. StaticInner in =
New StaticOutter. StaticInner ();
Local internal class
Internal class inside the Method
1. access modifier www.2cto.com is not available
2. Access the local variables in the method and all attributes and methods in the class.
3. If there is a local variable in the local internal class blocking method, the local variable cannot be accessed within the local internal class.
Anonymous internal class
Callback method, internal class without class name
1. There is only one non-argument constructor In the subclass.
2. The instance must be instantiated immediately.
Abstract class
Classes declared in abstract form
As long as a class contains an abstract method, this class must be a cabling class.
Abstract classes do not necessarily contain abstract methods.
Abstract classes can inherit abstract classes. All abstract methods are implemented by the first non-Abstract subclass.
Abstract method, implemented by the first non-Abstract subclass
As long as there is an abstract method, the class must be an abstract class
Abstract classes do not necessarily contain abstract methods.
Cannot abstract attributes
Abstract methods cannot be declared as private or final methods.
Interface:
Java multi-Inheritance
An interface is a description of a set of requirements, instead of a class.
100% Abstraction
All methods are abstract methods.
All methods are abstract by default, so you do not need to mark the method as abstract
All variables are static final variables by default.
Implements: Implementation Interface
Class A implements Interface
Interface inheritance interface, which can implement multi-Inheritance
Interface B
Interface C
Interface A extends B, C