An. operator
1. Arithmetic operators:
- +: plus or positive;
- -: minus or negative;
- *: Multiply;
- /: except;
- %: take surplus;
- + +: Self-growth operator, written in front of the variable to indicate the first self-increment and then assign value, write after the variable to indicate the first assignment and then self-increment;
- --: Self-reduction operator, usage same + +;
2. Relational operator: it must return a Boolean value;
< > >= <= = = =!
3. Logical operators:
! & (and); && (short circuit and) This differs from & in that if the operator returns false in front of it, the code behind is no longer running;
| or; | | (short circuit or);
^ OR: The variable is converted to 2, the same number of digits is 0, the number of different digits is 1, example: 2^3 output is 01;
4. Bitwise operators:>> << >>> (unsigned Right shift) ~ (opposite)
5. Assignment operators:
= + = = *=/=%= (modulo)
6. String Connection: + When the result is displayed, as long as a parameter is a string, the entire output is a string;
7. Ternary operator (expression) (trinocular operator):
Boolean value? Value 1: Value 2 Boolean is true return value 1;false return value 2;
8. Operator precedence (common)
1 ()
2 + +--~!
3 */%
4 +-
5 >> << >>>
6 < > <= >=
7 = = =!
8 &&
9 | |
103-tuple operator
11 Assignment operators
Two. Definition of variables
1. How variables are declared: variables that do not have an assignment in the underlying data type cannot be used;
int x; int x = 5; int x, y; int x = 5, y; int x = 5,y = 5; int x = y = z = 5; the first two types are generally used;
2. Character variable assignment:
char c = ' a ';
char c = ' Medium ';
char c = 98; 0-65535
char c = ' \ n '; Escape character
char c = ' \u0061 ';
3. Define an integer variable by default to int; Example: long L = 88888888888L;
4. Define a floating-point variable by default to double; example: float f = 12.345F;
5. Scope of variables
{code block} A variable declared in a scope can only be valid at this scope;
Eclipse Interface Description: The project browser on the left, the upper middle is the work area, the lower part is the error display area
Basic Main method format:
public class Test1 {public static void main (string[] args) {System.out.println ();//Shortcut Input SYSO Press and hold alt+/enter to quickly recall;}
JAVA Fundamentals 2