Constructor: The ⑴ method name is the same as the class name, and there is no return type (including void);
⑵ no return value;
⑶ If there is no input constructor, the JVM will automatically help us create a constructor without parameters, without any function body;
If we created the other constructors manually, we would not have created this constructor without parameters;
⑷ in general, if you want to implement your own construction method, it is best to overload a constructor without parameters.
Function overloading: Refers to multiple functions can use the same function name, as long as their parameter list is different, the meaning of similar functions, named the same name.
Overload Summary: ⑴ function overloading means that multiple functions use the same name;
The condition of ⑵ overloading is that the number and type of parameters are different;
⑶ overload effect: Reduce the difficulty of the call;
⑷ when calling overloaded functions, the computer layer matches itself according to the arguments.
Examples:
Public Noddle () {
This.bowltype = "Large bowl";
}
Public Noddle (String b) {
Bowltype = b;
}
Public Noddle (String bowltype, String type, Boolean moremeat) {
This.bowltype = Bowltype;
This.type = type;
This.moremeat = Moremeat;
}
Java Constructors and function overloading