After half a month of learning, Java has a small part of the understanding, this week mainly for the process control and arrays of learning now talk about their own ideas great God see Thanks to correct grateful!!!
There are three kinds of process control, sequential selection and circulation.
Choose to have three (If-else) (Nested IF statements) (Swith)
Syntax structure:if (conditional expression) {statement block 1;}else{statement block 2;}( in if-else statement, else is optional, execute statement 2 when the condition is mature when statement 1 is not mature)
if (conditional expression 1) {statement block 1;}else if (conditional expression 2) {statement block 2;}else if (conditional expression 3) {statement block 3;}
(if nested statements and if statements are also not executed when the condition is immature )
swith (expression) {
Case Judgment value 1: statement block 1;break; The switch statement is also used in conjunction with a case statement when the program executes when the condition is met.
Case Judgment Value 2: statement block 2;break; only one statement can be executed, none of the others are executed
nbsp case Judging value 3: statement block 3; Break; in a switch expression is a constant with a value of byte char Shor int, and the amount expression cannot be used with floating-point type , &NB Sp , &NB Sp Long type
·········· A switch statement can replace a branching structure that consists of multiple if-else statements
Case Judgment Value N: statement block N;break;
Default: statement block n+1}
The cyclic control structure stipulates that the condition is repeated, and the object is called "Circulating body". The Java Statement Loops 123,while, Do-while, and for.
Syntax structure: while while (Boolean expression) {loop body};
Do-while do{Loop Body}while (Boolean expression);
For for (expression 1: expression 2; expression 3) {loop-body};
The difference between the while and the Do-whlie statement is that the former statement is the first to judge after executing the second latter statement is the first to execute the loop body in the judgment;
The while statement applies to a looping program that is not known to construct the number of cycles Do-whlie used at least once.
The FOR Loop statement is the most powerful loop statement expression 1, which is typically the initialization variable value, and expression 2 is the value that determines whether the loop body executes the Boolean expression that it returns.
If true, the loop body is executed, and if False, the loop body is not executed and the loop is exited. The expression 3 is evaluated after the previous execution of the true loop body. In this process, the general
The loop body variable is modified, and the next loop is resumed after the expression 3 is executed.
Control transfer Statement break statement and Continue statement
The break statement can be used for any loop control structure, thus terminating the loop immediately. When a process encounters a break statement, whether it is a cyclic calculation or what the value of a Boolean expression is
The control flow will be transferred to the next statement following the loop. The continue statement inside the Loop statement is the end of the loop and the next loop does not terminate the loop.
The biggest difference between them.
An array of arrays is a collection of data of the same type
Array syntax: data type [array length] array variable name int [ten] A;
Data type array variable name [array length] int a[10];
The length declaration of the array: int [] a = new int [5]; declares a array of length 5
int [] b = {1,2,3,4,5}; length is 5 value is 12345
int [] c = new int[]{1,2,3,4,5}; An array of length 5 with a value of 12345
The characteristics of the array:1, the array is a data structure that can hold a set of information, the space is continuous, it also occupies a memory address, so the data is a reference type.
2, an array can only hold one type of data, you can save the basic type, you can also save the object. An int, a string cannot be saved simultaneously in a number
Within the group.
3, the array once defined can not modify the length, if you want to modify the new array must be defined or reference other arrays, so the array flexibility is poor.
4, the array variable holds the address of the continuous space element, the array element subscript starting from 0 The maximum subscript is the length-1.
5, (array name. Length): Is the number of control team leader degree
Array replication:
Syntax:system.arraycipy (a,0,b,0,3)
Int[]a = {0,1,2,3,4,5,6,7,8,9};
Int[]b = b[3];
B[3] = {0,1,2};
This means that the value of array A is copied to array b from the first bit of array A to the first bit length of array B to 3.
The same array can be copied directly, and array duplication of different lengths will overflow, with one-dimensional arrays, two-dimensional arrays and multidimensional arrays in the same type
Root Class object
You can define any type of integral type in the object root class
Come out and learn java3.