The main construction method is to create an instantiated object of the class, but the initialization of the instantiated object is done. Declaration format:
Constructor method's modifier list class name (method parameter list)
Construction methods can be overloaded as well as normal methods.
Characteristics of the construction method:
The constructor method name must be exactly the same as the class name.
The constructor method does not have any return value type, neither the return value nor the shut-off void can be joined, but it is not a construction method, it becomes the common method.
any construction method, if there is no definition displayed, the system defines a default constructor for the class that does not contain any arguments . If the constructed method is defined, the default constructor with no parameters is not created by the system.
Recommendation: When writing a construction method, be sure to add a parameterless construction method.
This article is from the "Gaogaozi" blog, make sure to keep this source http://hangtiangazi.blog.51cto.com/8584103/1661087
Constructors in Java