I. Re-understanding of the self-increment operator
The first thing to understand is that operators are symbolic representations of operations, and each of these operators represents a specific operation. The forms of these operations are various, and here we will re-discuss the increment operator, which is the symbol + +.
A demonstration of the self-increment operator results in the following:
We began to assume that the increment is based on its own numerical value, the constant is added, the constant can not be 1, when we detect the error. There are two errors here, self-increment is fixed plus one, and the self-increment operator is fixed, that is, + + does not need to add a constant.
We re-wrote the Java source program, with the result of DOS detection:
Two. Talk about the case analysis of the self-increment operator when participating in complex operations
The DOS detection results show the error of missing precision. Shows that we are not familiar with the Java default type rules. b*a++, the computed result is the default int, when the result is assigned to a byte type, the current result is 12, although there is no more than the range of byte, but because the right side is the calculation of the variable, so the report is likely to be more than the range defined by the byte, so it shows " There may be a loss. " If we redefine an int c=1; c=b*a++; DOS results are displayed as normal. In the case of a constant int type, the system automatically determines the size and then enforces the type conversion. If it is an operator such as + =, the system will also automatically determine, cast.
If we are in the range of the main function, write the byte a=3,b=4 directly; and b*a++; Then the output b,dos will be displayed b*a++ is not a statement.
Java-Preliminary Understanding-Chapter II-Arithmetic operators 2 continued