Java classes siege lion employment

Java siege lion employment class

 

1: Method (control)
(1) Method: is the completion of a particular function block.
Note: In many languages there are defined functions, and in Java, the functions are called methods.
(2) Format:
modifier return type method name (parameter type parameter name 1, parameter type parameter name 2 ...) {
method body statement;
return return value;
}

 

Modifiers: Currently on the use of public static. And then other modifiers later explain in detail
the type of the return value: the result is a function of the data type
method name: that has a name, we call this convenient method.
Parameter Type: data type parameter is a
parameter name: is variable
parametric classification:
arguments: operation involved in the actual data
parameter: the defined method for receiving variable actual parameters of
the method body statement: function code block is complete
return : end method
return values: that is the result of the function, the return gives the caller.
(3) two clear:
Return Value Type: data type of the result
parameter list: the number and type of the corresponding parameter data
(4) method call
A: clear return a value of
a: separate calls, no sense
B: Output calling, not very good, because I might not need the results of further action. But in general I would use the lecture.
c: the assignment call, the recommended program
B: void type method for modifying
a: separate calls
(5) Case:
A: summing scheme
B: obtaining the larger of two numbers
C: Compares two identical data
D: Get the maximum number of three
E: output star m rows and n columns
F: nn outputs the multiplication table
Note (6) method
a: a method call does not
B: the relationship between the same level is not nested definitions
C: The method defined time parameter is, separated
D: when the method is called, not in the delivery data type
E: If the return value of the method has a clear type, you must have a return statement returns.
(7) The method of overload
in the same class, the same method name, a list of different parameters. It has nothing to do with the return value.

A list of different parameters:
the number of different parameters.
Parameters corresponding to different data types.
(8) The method of overload case
of the comparative method of a plurality of different types of the same name.

2: Array (master)
(1) an array of: storing a plurality of container elements of the same data type.
(2) features: each element has a number, starting from 0, the maximum length code is -1.
Number is called professional: Index
(3) Definition Format
A: Data Type [] array name;
B: a data type array name [];

A mode is recommended, B method to forget.
However, to be able to read
the initialization (4) of the array
A: Dynamic initialization
is given only to the length of the default value, the system

For example: int [] = ARR new new int [. 3];
B: the static initialization
given value, the system determines the length

For example: int [] arr = new int [] {1,2,3};
Starter: int [] = {l, 2,3} ARR;
(. 5) of the Java memory allocation
A: local variable stack storage
B: All new heap storage out
C: method region (object-oriented portions of the detailed explanation)
D: native method area (system related)
E: register (CPU usage)

Note:
A: Variables Local variables are defined in the method definition statement or a method.
b: stack memory and heap memory of the difference between
the stack: data used up, it disappeared.
Heap: Each has a new address something out
of each variable has a default value of
byte, Short, int, 0 Long
a float, 0.0 Double
char '\ u0000'
Boolean to false
reference type null
data after use, the garbage collector Idle when recycling.
(6) FIG memory array
A: an array
B: two Array
C: three arrays (two stack variables point to the same memory heap)

/ *
Method: complete code block specific function.

Note: In many languages ​​there are defined functions, and the method is called in Java function.

Method Format:
modifier return type method name (parameter type parameter name 1, parameter type parameter name 2 ...) {
method body statement;
return return value;
}
detailed explanation:
modifier: to use the current public static. We'll explain in detail later in other modifiers.
Return Value Type: Results of that data type.
Method name: conform to the naming rules. The convenience of our call.
Parameters:
actual parameters: that is actually involved in operations.
Formal parameters; the method is defined for receiving the actual parameter.
Parameter type: is the data type of the parameter
Parameter name: variable name is the
method body statements: completion code is functional.
return: the end of the process.
Returns: is the result of the function, the return gives the caller.

To write a method, it must clear two things:
A: Return Value
result of data type
B: the list of parameters
you want to pass a few parameters, and data type of each parameter

Demand: Demand and the data of the two cases

Execution feature of the method:
do not call, do not perform.

How to call it (there is a clear call to return value)?
A: separate calls, in general does not make sense, it is not recommended.
B: output calls, but not good enough. Because we may need further action on the results.
C: Assignment call recommendations.

*/
class FunctionDemo {
public static void main(String[] args) {
int x = 10;
int y = 20;

@ 1 embodiment: individual calling
// sum (x, y);

// Mode 2: Output calling
//System.out.println(sum(x,y));
//System.out.println(30);

@ Embodiment 3: assignment calling
int Result = SUM (X, Y);
// Result herein may operate
System.out.println (Result);
}

/ *
Demand: demand and the data of the two cases

Two clear:
Return Value Type: int
parameter list: two are int.
* /
Public static int SUM (int A, int b) {
How // achieve it?
// int c = A + b;
// return c;

// c is a + b, so I can be returned directly to a B +
return a + B;
}

}

Inside the accident I found out for everyone to share a Photo

 

Guess you like

Origin www.cnblogs.com/itpy/p/11820453.html