Three kinds of call format 6.2 JAVA method

Three kinds of method invocation format:

  1. separate calls: Method name (parameter);

  2. Print call: System.out.println (method name (parameters));

  3. call assignment: variable name = data type name method (parameters);

Note: The method had to learn to write for the fixed return type void, this method can only be invoked separately, can not be printed or call assignment calls.

 

Method Example:

{class Demo02MethodDefined public 
    public static void main (String [] args) { 
        // separate call 
        SUM (l, 7); 
        System.out.println ( "===============") ; 
        // print call 
        System.out.println (SUM (1, 7)); 
        System.out.println ( "==============="); 
        // assignment calls 
        int num SUM = (15, 25); 
        NUM + = 100; 
        System.out.println ( "variable values:" + NUM); 
        System.out.println ( "============== = "); 

    } 
    public static int SUM (A int, int B) { 
        System.out.println (" method of performing it !!! "); 
        int Result = A + B; 
        return Result; 
    } 
}

  

Results of the:

Guess you like

Origin www.cnblogs.com/sdrbg/p/11108751.html