java foundation -4. Method

First, to get started

1 Overview

  • Methods: a feature extracted, the code is defined in a single playing brackets, form a single feature. When you need to use this feature. I went to call this method, so that is realized the reusability of code, but also solve the redundant code.

    2, the definition of the method

  • Definition format
    修饰符 返回值类型 方法名(参数列表){
        代码。。。
        return;
    }
  • Definition Format explanation:
    • Modifiers: The current wording is fixed public static.
    • Return Value Type: Fixed current wording void.
    • Method name: identifier meet specifications, used to call the method.
  • The method of naming
    • The method of naming variables, the use of a small hump.
    • Procedure: Use any of the statements contained in braces.
  • Call the format method
    方法名();

Guess you like

Origin www.cnblogs.com/phanx/p/12426532.html