One, the data type in Java:
Ii. scope of expression of each type
Type |
Occupy Storage space |
Table Count Range |
Byte |
1 bytes |
-27~27-1 ( -128~127) |
Short |
2 bytes |
-215 ~ 215-1 ( -32768~32767) |
Int |
4 bytes |
-231 ~ 231-1 ( -2147483648~2147483647) approx. 2.1 billion |
Long |
8 bytes |
-263 ~ 263-1 |
Three, three representations of the Java language integer constants:
A) a decimal integer, such as: 99,-500, 0.
b) An octal integer that requires a 0 start, such as: 015.
c) Hexadecimal number, requires 0x or 0X beginning, such as: 0x15.
Iv. Test Data Program
Public classTestdatatype { Public Static voidMain (string[] args) {//[√] since 10 in 2 of the 31 square ~ 2 of the 31-1 this range class inta=10; /*[X] because 5555555555 does not-2 of the 31-square-2 of the 31-square-1 This range class (about the plus or minus 2.1 billion or so) the literal 5555555555 of type int is an out of range */ intb=5555555555; //[√] since 20 in 2 of the 7-square ~ 2 of the 7-1 this range class ( -128~128-1) CharC=20; //[X] because 200 does not-2 of the 7-square-2 of the 7-time Square-1 This range class ( -128~127) Chard=200; //[√]declares a long type, plus l at the end Longe=5555555555l; }}
Note: The initial period of the automatic type conversion is that the number of conversions must be within the stated range of its type and the range of data types after conversion must be greater than the range of data types of the converted number, otherwise compile errors or loss of precision
007_ integer type