java method (function)

  java is object-oriented programming language, an object is an instance of the class, an object class is a template, and the method is used to achieve the object.

  Class is the real world or thought world entities reflected in the computer, it will operate on the data package and the data together. Class may be designated as private (private), public (public) or protected (protected). When using class functions, should pay attention to call its privileges (if it can be called) and its scope (what functions can be used in a range of data and functions).

  The method is used to define the role and function of the class, and is used for assigning a reference to the class. In java, the class is the outline of a program, but the class presented the final function is determined by the method.

  Private member function can be called by other member functions of this class, the class can not be invoked outside. Member function can access any member of the class (including public and private), valid data can be referenced in the present scope. The general practice is the need to be a member function calls outside of designated public, they are kind of external interfaces.

  It should be noted that not all the requirements of the member functions are designated as public. Some functions are not ready for the outside world to call, but the member function-oriented class called, you should specify them as private. Role of this function is to support other operating functions, other members of the class of utility functions (utility function), external users can not call these class private utility functions.

  Class member function is a very important part of the body. If the class does not contain a member function, it is equivalent to the structure in the C language, does not embody the class in object-oriented action program design.

(1) Method: is the completion of a particular function block.
Note: In many languages there are defined functions, and in Java, the functions are called methods

(2) Format:
modifier return type method name (parameter type parameter name 1, parameter type parameter name 2 ...) {
method body statement;
return return value;
}

Modifiers: public private etc
Return Value Type: is the data type Results of
method name: that has a name, we call this convenient method.
Parameter Type: data type parameter is a
parameter name: is variable
parametric classification:
arguments: operation involved in the actual data
parameter: the defined method for receiving variable actual parameters of
the method body statement: function code block is complete
return : end method
return values: that is the result of the function, the return gives the caller.

Guess you like

Origin www.cnblogs.com/look-up-at-the-starlit-sky/p/11504414.html