1, sequential structure: that is, follow the procedures of the relationship, in turn, execution.
2. Select Branch: Use IF. else,/switch () {Case [This must be constant]:}; /If.. else if ..... .... else.. Such statements let the program switch execution in different branches.
3, Loop structure: Repeat the completion function, you can use while () {} (first to judge and then execute); Do{}while (); (First execution and judgment); for (initial value; end condition; loop control variable);
Note: Where the loop can be nested, nested when the first to determine whether the outer loop is satisfied, and then into the inner loop, after the completion of the inner loop tube, until the condition is not satisfied, then exit to the outer loop, and then judge the outer loop is not satisfied with the loop condition, if satisfied continue to jump into execution, if not satisfied, Then jump out of all loops;
Break , and continue two end-of-condition explanations
Break is the end loop, exit Loop ****continue is the end loop start the next loop;
when there is a multi-layer loop, if you use break, just exit the loop, if you need to exit all loops, you should give a label at the beginning of the entire loop, and then inside the loop with (break tag;) so that execution to break will jump out of all loops.
* * How to define a label: "tag name":; it needs to be defined before the loop.
4, through the method of sorting to explain the basic algorithm, respectively, bubble sorting method, and the choice of sorting method;
bubbling Method: Bubble Sorting method is to use the previous number and the next number to compare, if the number of > after the Exchange position, and then always compare, get the last number is the largest, the equivalent is the largest in the water as the largest buoyancy, to come out, so that every time can only find a maximum value , until all the data, so the need to loop nested methods, the outer loop control how many rounds, the general number of data (such as 8), it is necessary to compare 8-1 times, and the main loop is to do a comparison, find the largest, because the last number does not need to compare, so each comparison of the number of cars on the original basis of the less , that is, 8-1-i (i is the variable of the outer loop).
Select Sort Method: The basic idea of choosing a loop, in fact, is a reverse process of bubble sort method, and the bubble sort method is to compare the value after the first round and put it in the last place. After the next round to do the comparison of the last value is not tube, and the choice of sorting method is every comparison round, the value of the found in the front, the next round of comparison does not need to tube, so I think can be calledSinking Method, also need two cycles to control, nested use, the outer loop control comparison of the number of wheels, of course, the comparison is also n-1 times, and the inner layer of the cycle, each comparison of the number of cars on the original base of the less once. But we find the value of the label in front, so the initial value of the inner loop should always be changed, after the comparison, the initial value should be added 1 on the original basis, that is, j=i+1, but the loop end condition will not change, also (n-1), because you want each time the initial value plus 1 has been reflected in the number of less comparison.
4, API Usage: Application programming interface. You can view the method inside and choose Invoke, which is a tool. can be queried directly. Use more, look more.
Getting Started with Java (3)-Looping, selecting, basic algorithms, API concepts