# # #基础语法 (2) # # #
1. Assignment operators
Basic assignment Operator: =
Extended assignment Operator: +=,-=,*=,/=,%=
(Add/Subtract the value to the left of the equals sign and to the right of the equals sign ...). The result of the assignment equals the variable to the left)
We can see here a + = 10 equals to a = a + 10
2. Keyboard entry: Provides a class through Java---Scanner: text scanner
Basic format:
Scanner Scanner = new Scanner (system.in);
There will be an error, here we need to import a package, written between the packages and class
int number = Scanner.nextint (); "Call Scanner Method"
Here we give the example: the maximum value of the three numbers to be entered
3. Logical operators
Basic logical operators: Logic and-&, Logic, or-| , logic or-^, logical non-!
&: false False |: True True
^: The same as false differs to true
!: Not false true, false if not true, even number not for itself
difference between && and &: If False first occurs, the back of the non-execution is the effect of the rear
|| Difference from |: If first appears true then the back of the non-execution is the effect of the rear
4. Arithmetic operators
+,-,*,/,% (Take surplus)
++/--self-increment 1 or self-minus 1
Special: If ++/--data before the operation: Increment 1 or decrement by 1, then the operation (Assignment)
If the ++//participates in the operation after the data: the first operation (Assignment), then the participating operation
5. Ternary operator:? True:false
Example: Comparing three number sizes
6. Select the IF statement for the structure statement
1) if (conditional sentence) {}
Example: Enter a number when the output is greater than 8 o'clock, when it is less than 8 o'clock end.
2) if () {}else/if () {}else if
if (statement) {statement 1}else{Statement 2}
Example: Enter 1-24 to determine the time of the afternoon of the evening
# # # #END # #
Related articles:
Introduction to Java Tutorial (ii) installation using Eclipse
Introduction to Java Tutorial (iii) Basic syntax (1)