All functions in Java belong to a class. Therefore, the main method in Java must have a shell class.
The main method in Java must be static.
public class ClassName{ public static void main(String[] args) { program statements }}
Java is portable, and its data types occupy a fixed amount of space.
Integer: int 4 bytes, short 2 bytes, long 8 bytes, byte 1 byte
A long value has a suffix L, and a hexadecimal value has a prefix 0x.
Java does not have the unsigned type
Floating Point: Float 4 bytes 6 ~ 7-bit valid number, double 8-byte 15-bit valid number
A float value has a suffix F. The default value without a suffix is double.
In C ++, a value or pointer can replace a Boolean value. 0 is equivalent to false. A non-0 is equivalent to true, but not in Java.
C and C ++ differentiate the Declaration and definition of variables, for example, int I = 10; is to define a variable, and extern int I; is to declare a variable, java does not differentiate the Declaration and definition of variables.
Java uses the keyword final to define constants, similar to const in C ++.
For Boolean values, & and | are calculated in short-circuit mode, that is, if the first expression can get the result, it does not have to calculate the second expression, & | is not calculated in short-circuit mode.
>>> The operator fills the left digit with the symbol bit, >>> the operator fills the left digit with 0.
Constants and variables