6.1 Method and Method overloading

How to use the method with parameters

Defined parameters of the method

To write public (access modifier) ​​return type <method name> (<formal parameter list>) {} // body issued

Call methods with parameters

Object name. Method name (parameter 1, parameter 2, ..........., parameter n)

 

 

Methods of knowledge

A method of defining a parameter called the formal parameters, also called the parameter (the parameter of major constraint type)

2 parameter names can easily take, but to meet the hump naming, while meaningful

3 method calls, parameters called the actual parameters, also called the argument

4 and the argument class type parameter must be the same name may be identical, or may not coincide

5 method has no return value, parameters and methods have no, nothing

6 there may be a method parameter, there may be a plurality of, spaced between a plurality of parameters (in the formal and actual parameters are) comma

7 for formal and actual parameters must be consistent with the amount, type of data must be consistent

 

 

The method of parameter passing

When the transmission basic data type parameter, the parameter change is not retained (parameter int, basic data types) pass substantially Parameter Type Value

When the parameters are passed to reference data types, parameters are retained (custom data types, data interfaces, reference data types) pass-reference data types

 

Guess you like

Origin www.cnblogs.com/qq839154187/p/10959983.html