Method overloading: define a set of methods, these methods have the same name, a similar effect, with different parameters
Three elements
1, the method names are the same
2, different parameter list
1) number of different parameters
2) sequentially different parameters
3) Different types of parameters
3. Scope
Precautions:
1, regardless of method overloading return type, i.e., only the method returns a value of different types, does not constitute a method overloading
2, also known as a static method overloading polymorphism (at compile time already know what execution method)
3. Method Is also called compile time polymorphism at compile time because the method can determine the specific calls
4, try not to talk about a wholly different method overloading
this
1, each member of this method are implicitly a reference to the application object it always points to call
Address 2, key members of this class calls the method given object
3, every time we call a member method, the compiler will address methods to assign an object to this call
Static variables static
1, in front of the property or method members plus static can become a member static member
2, static members are shared by all object classes, directly accessible by the class name. Name is generally not referenced by object
3, static members can before the class is instantiated by the class name directly access
4, static member variables in the class when the class is loaded allocated space, static members throughout the life cycle of the application
5, static method can only access static member variables
6, static method does not this quote
Static block static {}
1, is mainly used for static variable class assignment
2, it will only be called once when the class is first loaded
Common code blocks {}
1, two kinds of code blocks are executed before the constructor
2, static blocks only the first time you call
3, only static block will run automatically when you call the static method does not run automatically, just apply for space at load time
Static member initialization process
1, the space allocated to the static variable and given a default value
2, to the static variable is assigned an initial value