Data types determine how data is stored and how it is operated
Integer type:
Java each integer type has a fixed number of table range and field length, not affected by the specific operating system, to ensure the portability of Java programs
Constant:
three representations of integer constants:
? decimal integer, such as 12,-314, 0.
An octal integer that requires starting with 0, such as 012
Hexadecimal number, which requires 0x or 0X, such as 0x12
Binary number, beginning with 0b or 0 B, such as 0b00010010 (JAVA7 or more)
1. The default is int type
2. Declare a long constant can be followed by ' l ' or ' l ', such as: long L = 3L.
3. There is no "unsigned number" in Java, you can use long to process unsigned integers (UINT)
Floating-point types:
Constant:
Two types of representations:
The decimal number form must contain a decimal point, for example: 3.14 314.0.314 Java7 Above: 123_456.789_000 (the thousand-bit separator is underlined)
scientific notation forms, such as 3.14e2 3.14E2
1. The Java floating-point constant defaults to double type,
2. To declare a constant of type float, add F or F after the number, such as float f = 3.14f;
Character type:
1. Java characters are Unicode encoded with two bytes per character
Can be expressed in hexadecimal encoded form
char c1 = ' \u0061 ';
2. Character constants are single characters enclosed in single quotes
char c = ' A ';
3. Escape character ' \ '
char c2 = ' \ n '; Represents a newline character.
Boolean type:
Boolean data only allows values of true or FALSE, and cannot replace true and false with integers of 0 or not 0
The difference:
Boolean true // // declare int variable float// declare float type variable and assign double// declares a double variable and assigns the value char// declares a char-type variable c = ' \u0031 '; // Assigning a value to a char type variable // Assigning a value to an int type variable
Java, data type