In a class, you can define a special method-the construction method.
Construction method: Used primarily to create objects, which can specify the state of an object at the same time.
The main differences between the construction method and the common method are:
1. Cannot have a return value.
2. The name of the construction method must be exactly the same as the class name that contains the constructor method of the class.
Attention:
A constructor with parameters is written, the value of the parameter must be specified when the object is created, and if the constructor method is not written, the compiler creates a parameterless construction method by default.
In a class, you can define multiple construction methods, which involve overloading the method.
Because the constructor name must be exactly the same as the class name, the compiler can only differentiate between different construction methods by the number, type, and order of the arguments.
The Java compiler uses a method signature (collectively known as the method name and parameter list) to distinguish between different methods, the method name and the parameter list, excluding the return value.
java--Construction Method