java function personal understanding

First, the definition of the function

            Function is defined by the function name, parameters, return type and a method of body composition, the modular processing step is performed and the program has program functions independently performed, these independent code blocks can be reused, reducing redundancy codes It, reducing the amount of codes of the main codes, but also facilitates memory optimization.

Second, the function is called

  1.  Call functions have different permissions, divided into public, private, and different rights protected.
  2.  Call functions can be overloaded if the argument list function, a function of different types to represent different functions and thus perform the same function name but the same function.
  3. Function's return value type is compatible, the return value is returned to the calling function, it also means the end of the function is invoked to run

Third, the function parameters

  1. Parameter :( formal parameters) variables defined in the first method is called the formal parameters, local variables must be in the form of parameters.
  2. :( actual parameter to pass a value argument) parameter to call the method, the value is the actual parameters.
  3. Argument is a constant in the constant pool address or target address in the heap memory passed parameter.

Fourth, the function stack

  1. Running the function stack-based memory at the time.
  2. After a stack is advanced out of the memory structure. The main function is generally the most advanced stack, the final out of the stack, but also represents the ultimate end of the program.
  3. When the function returns a return means that when the program is over, this function pops up when the program stack.

Fifth, the function calls the recursive algorithm

       For details, see my blog post another Tower of Hanoi (classic case of recursive calls), not described in detail here.

Sixth, there are many commonly used functions have been divided into two categories defined in the function

  1. String class
  2. Math class

     Good use of commonly used functions can greatly help us to shorten the amount of code, reduce work duration.

     See java manual

Released seven original articles · won praise 0 · Views 132

Guess you like

Origin blog.csdn.net/weixin_43748564/article/details/104348012