Arrange at will, please point out any mistakes
basic data type
Integer type
byte 8-bit binary (-128-127)
short 16-bit binary (-32768-32767)
int (default) 32-bit binary ( -2^31 ~ 2^31-1 )
long 64-bit binary (-2^64 ~ 2^64-1)
floating point type
float single precision
double (default) double precision
character type
char character type
Boolean value
boolean variables can only be defined as true or false
operator
arithmetic operators
+ - * / Addition, subtraction, multiplication and division (strings and any data are connected with "+", and the final return result is a string)
% Take the remainder (when a negative number occurs, only look to the left of the sign; for example: 5%-2=1, -5%2=-1)
\ Escape character: use "\" to change the meaning of the following letters or symbols
For example: \n newline
\b Backspace (equivalent to BackSpace)
\r Press the Enter key, the carriage return character in Windows system is represented by two characters "\r\n"
\t Tab character (equivalent to the Tab key)
assignment operator
= For example: int a=1 assigns the number "1" to the int variable "a"
+= a+=1 is equivalent to a=a+1
-= a-=1 is equivalent to a=a-1
*= a*=1 is equivalent to a=a*1
/= a/=1 is equivalent to a=a/1
%= a%=1 is equivalent to a=a%1
comparison operator
== equals ("=" is assignment, "==" is equal)
! = not equal to
< less than
> greater than
<= less than or equal to
>= greater than or equal to
Logical Operators
Used to concatenate boolean expressions or values
& and true & true to true true & false to false false & false to false false & true to false
&& and true&& true true true && false false false && false false false && true false
| or true | true is true true | false is true false | false is false false | true is true
|| or true || true is true true || false is true false || false is false false || true is true
^ XOR true^true is false true^false is true false^false is false false^true is true
! not ! true or false! false is true
Difference between & and &&
When the & operation is performed, both sides need to calculate the true and false values.
When the && operation is performed, if the left side of the symbol is false, the right side of the symbol is not calculated, and the result is false
The difference between | and || is the same as above
bitwise operators
<< shift left
For example: 3<<2
>> shift right
For example: 6>>2
The result of the >> symbol is equivalent to a/(2^b), the result is an integer, and the decimal places are discarded
When the right shift fills, what is the highest bit is used to fill
>>> unsigned right shift
When shifting right, the highest bit is always padded with 0
& and 0&0 is 0 0&1 is 0 1&0 is 0 1&1 is 1
| or 0|0 is 0 0|1 is 1 1|0 is 1 1|1 is 1
^ XOR 0^0 is 0 0^1 is 1 1^0 is 1 1^1 is 0 (a number a is XORed with the same number b, the result is still a, used for encryption)
~ Negative ~0 is 1 ~1 is 0
Negative binary numbers are integers negated and added by one
--------------------By chick