And parameter arguments Description 09

Instructions and parameter arguments

Formal parameters : an inlet for use in the method herein, is defined as a variable parameter referred to as a method of entry variables.
Argument variables : the variables we defined earlier in the method is a kind of argument variables.
Description :

  1. Argument range of action is to start from the definition of '}'
  2. The scope parameter is defined from the start until the end of the method for performing the method.
  3. Generally variable argument parameter values ​​can be transmitted to the process.
  4. Argument variables typically requires the initial value, but not the variable parameter to the original value.
public class MethodDemo {
    public static void main(String[] args) {
        int age = 23 ; // 实参
        System.out.println(age);

        int a = 10 ; // 实参
        int b = 20 ; // 实参
        sum(a, b);
    }

    // int a , int b 是形参
    public static void sum(int a , int b ){
        int c = a + b ; // c是实参!
        System.out.println(c);
    }
}
Published 34 original articles · won praise 16 · views 296

Guess you like

Origin blog.csdn.net/qq_41005604/article/details/105165092