Tag: DDR public ATI res load join name cannot be the same
1: Signature of Method: Method name + parameter list is the signature of a method
2. Overloading of Methods (overload):
1) occurs in the same class, the method name is the same, the parameter list is different
2) The compiler will automatically bind methods based on the signature of the method at compile time
3. Construction Method:
1) often used to assign initial values to member variables
2) with the same name as the class, no return value type
3) is automatically called when creating the (new) object
4) Construction method can be overloaded
5) If you do not write the constructor method, the compiler defaults to a non-parametric construction method if you write the constructor method, it is no longer default to provide
4.this: Refers to the current object, which object invocation method refers to which object can only be used in the method, the method accesses the member variable by default there is a this.
The use of this:
1) this. Member Variable name------------Access member variable
2) this. Method name ()--------------Call method
3) This ()---------------------call construction method
4) This cannot be omitted when the member variable has the same name as a local variable
Demo of overloading
public class Overloaddemo {
public static void Main (string[] args) {
A o = new A ();
O.say ();
O.say ("join");
O.say (25);
O.say ("join", 25);
O.say ("join");
}
}
Class a{
void Say () {}
void Say (String name) {}
void say (int age) {}
void Say (String name,int age) {}
void say (int age,string name) {}
int say () {return 1;}//Compile error, overload is independent of return value type
void say (String address) {}//Compilation error, overload is independent of parameter name
}
I am a beginner, if the update is not good, welcome the Great God pointed out, thank you!
More exciting after the update, reprinted annotated!
java-Branch Overloading and construction methods