Java Learning Fourth day basic concept summary Two

Source: Internet
Author: User
Tags array sort

V. Program Control Structure

1, the structure of the program design

(1) Sequential structure: A program segment consisting of statements executed in writing order. Execute in the order of a sentence.

(2) Select structure: Also known as the branch structure, in many practical problems of the program design, depending on the input data and intermediate results of different situations need to choose different statement group execution, in this case, must be based on the value of a variable or expression to determine to decide to execute those statements and skip those statements do not execute.

(3) Loop structure: When a given condition is established, a program segment is executed repeatedly.

2, select structure

(1) If statement

(2) If...else statement

(3) If...else...if...else statement

(4) conditional operator "? : "

(5) Multiple Choice--swith statement

3, Cycle structure

(1) While loop

(2) Do...while cycle

(3) For loop

(4) Loop nesting

(5) Loop jump: Beak statement (exit loop immediately), continue statement (exit this loop)

Six, array

1, one-dimensional array

(1) declaring an array

(2) allocating memory to the array

Syntax 1:

Data type array name []; Declaring a one-dimensional array

Array name = new data type [number]; allocating memory to an array

Syntax 2:

Data type array name [] = new data type [number]

2, array length: array name. length.

3, the assignment of the initial value of the array:

Data type array name [] = {Initial value 0, initial value 1, ..., initial value n}

4, Array application example: Maximum minimum value (single loop), sort (double loop).

5, array-related API methods:

System.arraycopy (source,0,dest,0,x): Copies an array of x elements starting from subscript 0 to the target array, starting at the position corresponding to the subscript 0 of the target array.

Arrays.sort (array name): Array sort operation, need to import java.util package.

6, two-bit array

Way One:

Data type array name [];

Array name = new data type [number of rows] [number of columns];

Way two:

Data type array name [] = new data type [number of columns] [number of rows];

Assignment value:

Data type array name [] = {{No. 0 row initial value},{1th row initial value},... {nth row of initial value}}

Ps:java allows each row in a two-bit array to have the same number of elements locally.

7, length of two-bit array

(1) Array name. length//Gets the number of rows in the array

(2) array name [].length//Gets the number of specific row elements (number of columns for a particular row element)

8, reference and access to two-bit array elements (two-bit array)

9, multidimensional arrays: typically use up to three-dimensional arrays (data type data name [][][])

  

Java Learning Fourth day basic concept summary Two

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.