I am Zhang SAO Nian, quantum metaphysics believer, zuan surfer king, B station white piao master, tear less protection association senior member, a emotionless package machine.

Graduating two physics can not find a job, ready to use five months to switch to Java “upper society”

Hair loss diary



Today, the rain is so heavy, some cold, I think of you, do not know the future may not have your hair in the day, how cold will be.

It seems that every city will rain, just like I will miss you wherever I am.

As if without hair or hat will be cold, just like without you lonely heart will hurt.

Today the mood


Although it is raining, today is full of vitality. It seems that the school is going to reopen, and I have prepared for my online graduation defense. Unexpectedly, I have to go back to school to meet my “villagers”.



Again,Roommates meet do not know each other, laugh and ask fat man who you are.



This is a damn friendly roommate thing.



Lesson Objective for today

Learn the use of functions, lots of practice, practice, practice

Today’s Learning Difficulties

recursive

I don’t understand. Maybe later.

Study notes to summarize key points

Function concept and definition

A function is a piece of code that implements a specific function and can be used over and over again. Function placement: Functions are defined inside the class, alongside the main function.

Function syntax:

public static voidFunction name (){// Declare the function

     // Function body

}



Function names: Follow the naming conventions for identifiers

Copy the code
<br /> <br /> <br /> <br />Copy the code

Function call

Functions do not execute actively; code in a function needs to be called actively to execute. Function is a mobile phone, you can make a call, but the mobile phone will not actively make a call, you need to use the mobile phone to make a call. ** Calls a function: ** Calls the function name where the function code needs to be executed. Note: When a function is called, the internal code of the function is executed first, and when it is finished, it is returned to the function call and continues to execute.

For example, in the process of reading, we come across a word that we don’t know. We put down our books and look them up in the dictionary. Pick up your book when you find it



public class Day05 {

    public static void main(String[] args){

// Call the function

        test();

    }



// Define the function

    public static void test(a){

        System.out.println("Test function");

    }

}

Copy the code

The details of the function – the composition of the function

Function name: the name of the function ** Return value type: void (no return value) or specific type (primitive type and object type) how to write a function that returns a value

  1. Declare the return value type at function definition
  2. Returns a specific value when defining
  3. The return keyword
  4. The return value and declared data type must be consistent
  5. How does the caller receive
  6. Variable type consistency
  7. The return value of a function may not be accepted


public class Day05 {

    public static void main(String[] args){

// Call the function to get the return value of the function

        int a  = test();

        System.out.println(a);

    }



// Define the function to return a 1 each time the test method is called

    public static int test(a){

       return 1;

    }

}

Copy the code

Special usage of the return keyword

  • A function can have only one return value
  • Return terminates the function’s execution without executing the statement after return
  • Return: terminates the current function

Syntax requirements for function arguments

  • Data type, parameter name
  • Inside a function, use parameter values by parameter names
  • Parameters can only be used inside the function body, called local variables of the function


Nested calls and recursion of functions

Nesting between different functions, a called function can also call other functions recursive ???? I don’t understand

Learn nouns today

noun meaning
method methods
recursion recursive
parameter parameter
return return

Summary of today’s lesson