Operators, expressions, and operator expressions
Operator Classification
Arithmetic Operators: +,-, *,/, %, ++ ,--
Key Aspect 1:
Int I = 3/2;
What is the I value?
public class test{public static void main(String args[]){int i=3/2;System.out.println(i);}}
Key Aspect 2:
What is the difference between I ++ and ++ I?
After the plus sign, I participates in the operation of the entire expression and then adds 1.
public class test{public static void main(String args[]){int i=3;int j=i++ +5;System.out.println(i);System.out.println(j);}}
The plus sign is first added to the front I and then involved in the operation of the entire expression.
public class test{public static void main(String args[]){int i=3;int j=++i +5;System.out.println(i);System.out.println(j);}}
I -- the same as-I!
Relational operators: >,<,>=, <=, == ,! =
The result calculated using Relational operators is boolean.
public class test{public static void main(String args[]){int i=3;int j=5;boolean b= i == j;System.out.println(b);}}
Boolean logical operators:
! |
Non-logical |
& |
Logic and |
| |
Logic or |
^ |
Logic exclusive or |
&& |
Short circuit and |
| |
Short circuit or |
If one of a & B and a & B is false, the result is false.
A | B and a | if one of B is true, the result is true.
Differences between a & B and a & B:
public class test{ public static void main(String args[]){ int i=3; boolean a=i>5 & i++<10; System.out.println(a); System.out.println(i); }}
public class test{ public static void main(String args[]){ int i=3; boolean a=i>5 && i++<10; System.out.println(a); System.out.println(i); }}
If one of a & B is false and the result is false, when & is used for calculation, if the result of the Left expression of & is false, the result of the & right expression is not calculated. A and B determine whether the expressions on both sides are false.
Logical or similar to short circuit or!
Value assignment operator: =Extended value assignment operator: + =,-=, * =,/=
I + = 5 is equivalent to I = I + 5
Bitwise operators: &, |, ^, ~, >>, <, <
String concatenation operator: +
Expression type and value
An expression is the sequence of operators and operands.
The result of operations on the operands in the expression is the value of the expression.
The data type of the expression value is called the expression type.
Operators and expressions
B, C, and D indicate x/(yz)
A Indicates xz/y.
Operator expression-VisualBasic6
I. Operators
Arithmetic Operator: ^/\ (Division) mod (remainder)
Relational operators: The value can only be true, False, or null.
Is used to compare the reference variables of two objects
Like is used to compare the pattern matching of two strings and determine whether a string belongs to a certain pattern. Wildcard characters can be used.
* Multiple characters
? Represents a single character
# Represents a single number
[List] indicates in this range: [a-f]
[! List] indicates that it is not in this range, for example :[! A-f]
For example, the result of mm = "aBBBBa" like "a * a" is true.
Whether the string "aBBBBa" is a with both ends.
Comparison of strings: character-by-character comparison from front to back, and large ASCII code;
If the previous part is the same, the string length is greater;
Only strings with the same length can be equal.
When a table's bigint expression is a numerical value and the other is a variant, a numerical comparison is performed.
Concatenation operator: Used to merge strings. & + is used to force two expressions to join strings.
When "+" is used, it may be difficult to determine whether it is an addition or a connection. To avoid confusion, use the & as a connection operator.
Logical operators:
And
Eqv equivalent
Imp inclusion
Not
OR
Xor exclusive or
The priority is from high to low:
Arithmetic Operators → character concatenation → Relational operators → logical operators