Basic data type:
Byte 1 bytes positive or negative can represent 2 of the 8-1 square -128~127 (including 0)
Short 2 bytes 2 of 16-1 times
Integer type (default is int type)
int 4 bytes 2 of 32-1 Times Square
Long 8 byte 2 of the 64-1-time long type is defined with the number of L or L after the digit: Long is a = 2344534656348204L;
Character type Char2 bytes
Basic data types
Float 4 bytes
Floating-point type (default is double type)
Double 8 bytes
BOOL Type Boolean
Integral type
The number of positive and negative numbers represented by integers--one byte = 8 bit so the number that can be represented is 2 8, which is the first sign that becomes positive or negative, when the first is 0, the number is an integer and 1 is negative.
Wide conversion accuracy of small conversion to high precision, without loss of precision
Narrow conversion precision large conversion to precision know, will lose precision, will error
Character type
Character types are typically used to denote that a single character type must be enclosed in single quotation marks (').
Generally there are three ways to express:
1, directly specify a single character as a character value
char Achar = ' a ';
2, using the escape character as a character value commonly used transfer characters have \b backspace \ n line break \ r return character \ ", \", \ \ Double cited, single-lead, backslash
char Enterchar = ' \ r ';
3. Use Unicode encoded values to specify character values where 9999 represents a hexadecimal integer
char ch = ' \ u 9999 ';
Floating point Type
There are two ways to represent Java floating-point numbers: The decimal number form (the float must contain a decimal point), the scientific notation form
Float represents a single-precision floating-point number for 4 bytes 32-bit single precision immediately after the float type value F or f
Double stands for 8 bytes of 64 bits for dual-precision floating-point numbers
Only the positive float is divided by 0 to get the positive infinity, the negative float divided by 0 can be negative infinity
If an integer value is divided by 0, an exception is thrown arithmeticexcrption:/by Zero (divided by 0 exception)
Boolean type
The numeric value of Boolean can only be true or false, and cannot be substituted with 0 or not 0. Values for other data types cannot be converted to a Boolean type
A Boolean variable requires only one bit, but most of the time it actually occupies 8 bits (1 bytes)
Boolean values are automatically converted to strings when using the Boolean type of paper and word A for connection operations.
For example: String str = true + ""; The output will be output true
Java Learning Diary--Basic data types