java learning day8

arrays java class sort specifically for array operations,
ascending sorting method
Arrays.sort(arr);
dynamic initialization of the array
int[] arr=new int[x]
When initializing, only specify the length of the array, and the system assigns the initial value to the array
Integer initial value
The initial value of the decimal is 0.0 The
initial value of the character is ' ' The null character The initial value of the
Boolean is false The initial value of the
reference data type is null (empty constant)
There are two ways to assign an
array Definition, the length is fixed


Two-dimensional array The
array stores the array
int[] arr={{},{},{}}
====================== =================================================
Method
Method It is a code block that completes a specific function. There are function definitions
in many languages. Functions
are called methods in Java.
Format :
modifier return value type method name (parameter type parameter name 1, parameter type parameter 2...) {
    function body;
    return return value;  
}
One of the simplest methods can have no modifiers, parameters, and return
but must have a
return type
. Type, what is the type of the return value? A method will not be executed if it is not called, and it can only be called in the main method. Method invocation a. There is a static calling  class name. If the method is called in the same class, it can be omitted Class name b. Call without static  1. Create an object class name object name = new class name (); see which class the class name of the method to be called is in which class 2 call object name. method (); public as a Permission modifier Parameters , equivalent to express, used to transfer data Note: Parameters are not used to transfer parameter types Multiple parameters are separated by commas Each parameter must have its own data type There are parameters in parentheses in the method, which must be called when the method is called Passing parameters Method and method are equal, you cannot define the method return in the method Features used in the method 1. You can end the method 2. After the return, there must be a specific return value. When a method with a return value is called, a variable should be defined to accept the method Return the value or directly print the output























You can call the method directly without returning a value.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325824937&siteId=291194637