Methods and Overloading
class=”markdown_views prism-atom-one-dark”> Knowledge points: Define a method with parameters return type () { //The body of the method –parameters– What is the parameter? } Method parameter passing The difference between basic data types and reference data types when passing parameters Basic data type, the operation passes the value of the variable, and changing the value of one variable will not affect the value of another variable. Reference data types (classes, arrays and interfaces), assignment is to pass the reference of the original object (which can be understood as a memory address) to another reference Construction method Access modifier constructor name ( ) { //Initialization code } No return value type, the method name is the same as the class name, parameters can be specified, and the system provides a default parameterless construction method Constructor overload Custom constructors have the same method name but different parameter items, regardless of the return value and access modifier Method overloading —–> same name but different parameters Note: If there is a construction method in the class, the system will no longer provide a no-argument construction. If there is no construction method in the class, the system will automatically generate a no-argument construction Usage of…