One weeks of continuous classes, but also slowly adapted to the tense learning rhythm. Now let's summarize what we learned in Chapter two:
The second chapter is mainly about Java's Basic grammar, which consists of the following aspects: constants, variables, data types, keywords, identifiers, operators, expressions, annotations, and statements.
The data type is a key element of Java's control of memory, and Java allocates the variable or constant in memory space through a data type declaration, and labels it with a good name (that is, an identifier). Different data types, the amount of space allocated is not the same: the size of Byte,short,int,long in the integer is 1,2,4,8 bytes, the float,double in the floating-point type are 4 and 8 bytes, and the character char is 2 bytes. The Boolean type is unknown; the reference data type is represented by string as the largest space occupied. Different number types can be converted to each other, small space to the large space can be automatically converted, large turn small to use strong to the symbol "(data type)."
A variable is declared in the form of a data type variable name = value, and a constant declaration requires the keyword final to precede the data type. A variable declaration can change its value, but once the constant declaration cannot be changed.
The keyword is a predefined set of words in Java that comes with the system, and these words are not available when we define identifiers.
A statement in Java consists of a keyword plus one or more expressions in a certain syntax, followed by ";" at the end of each statement.
The expression is made up of some grammatical rules, such as the identifier plus operator and so on.
There are many operators in Java, some of which are similar to the operators in mathematics, such as +-*/(subtraction), which is the modulo operator (remainder), and + + is the self-additive operator, which is the self-subtraction operator, and if the two symbols precede the identifiers, the first one is added before the operation. If you put it in the back, do the arithmetic and then add minus one. The relational operator is the comparison operator, judging the size of the symbol, the return value is a Boolean type, such as > greater than,< less than, >= greater than or equal to, <= less than equals, = = equals,! = is not equal; The return value of the logical operator is also Boolean, with short-circuit logic and (&& Both sides must be true for real, short-circuit logic or (| | On the one side is true, not short-circuit logic and (&) Both sides must be true for true, not short-circuit logic or (|) side for the true other side for the false is true, logical non (!) Reverse. Then there is the bitwise operator & bit with, | bit or, ^ bitwise XOR, ~ bit non, and shift operator << left shift,>> right shift,>>> right shift 0, both of which operate in binary numbers. Finally there is the conditional operator (the trinocular operator, the operator with three expressions) in the form: expression 1? expression 2: Expression 3, the computer determines whether the expression 1 is true, or returns the value of expression 2 if it is true, otherwise returns the value of expression 3.
The final comment is that the comment is not compiled by Java, and is used as a description of the contents of the Java document and the meaning of the statement, it has three representations,//single-line comments,/* */Multiline comments and/** * * * */document comments.
Java Learning Chapter II Summary