The purpose of the construction Method (constructor) is to initialize objects when they are created, and a class can have multiple constructors that differentiate them from the overloads of the constructor (overload) depending on the number of arguments or the difference in the parameter type.
Features: 1. Each class has a constructor method, and an empty construction method is automatically generated without it.
2. The construction method is consistent with the class name.
3. The function of the constructor is primarily used to define the state of the initialization when the object of the class is created. It has no return value and cannot be decorated with void.
4. The constructor is not explicitly called and is called automatically when the object is created. Sometimes the parent class has a constructor that takes a parameter, and the constructor for calling the parent class must be displayed in the subclass, because the constructor of the subclass cannot find the constructor of the parent class when it is instantiated (the subclass does not have to show the call when the parent class has its own write-without-argument constructor).
There is no destructor method (destructor) in Java, but there is a similar finalize () method in object, and the Finalize method of the class is automatically called when the system is reclaimed. In a generic subclass, the Finalize method of the parent class is called to ensure that the parent collection works properly.
Day1-java-construction method and its destructor method