Variables and data types
In Java, the type of data can be divided into four types: basic data type, array type, class, and interface type. Any data must be one of the above data types.
The basic data types can be categorized into four main categories: Boolean, character, Integer, and floating-point. These types of data are basically the same type as the constants described earlier, and no more is said here. The following lists the range of values for integer and floating-point variables:
Table I,
Type width value range
BYTE 8-bit-256 to 256
Short 16-bit-32768 to 32767
int 32-bit-2147483648 to 2147483647
Long 64-bit-9223372036854775808 to 9223372036854775807
Table II,
Binary integer Long Integer
Decimal maximum positive integer 2147483647 (2 of 31 minor minus 1) 923372036854775807L (2 63-time minus 1)
Octal maximum positive integer 077777777777 (2 of 31 minor minus 1) 07777777777777777777L (2 63-time minus 1)
Minimum negative integer 020000000000 (-2 of 31 squares) 04000000000000000000L (-2 of 63 times)
Hexadecimal maximum positive integer 0x7fffffff (2 of 31 reduction 1) 0X7FFFFFFFFFFFFFFFL (2 63-time minus 1)
Minimum negative integer 0x80000000 (-2 of 31 Parties) 0x8000000000000000l (-2 of 63)
Floating-point numbers can be expressed from small to large, respectively: negative infinity, bearing limit, negative 0, positive zero, positive finite value and positive infinity. where positive and negative 0 are equal at the time of numerical comparisons, there is still a way to distinguish between the two values, such as the result of positive infinity when the 1.0/0.0 is carried out. Other finite values of non-0 non-infinity are expressed in s*m* (2^e), and the range of values for S and M is shown in the following table:
Table III,
Type S M e
float +1 or-1 is less than 2 of the 24-square positive integer 149 to 104 of the integer
Double +1 or-1 integers less than 2 of the positive integers 1045 to 1000
Table four, float maximum value 3640282347e+38f
Non-0 min value 1.40239846e-45f
Double Maximum value 1.79769313486231570e+308
Non 0 min 4.940656458412465334e-324
In addition, the floating-point number has some special values, see table below: float Max Float.max_value
Minimum value Float.min_value
Positive Infinity Large float.positive_infinity
Negative Infinity Large float.negative_infinity
NaN Float.nan
Double Maximum value Double.max_value
Minimum value Double.min_value
Positive Infinity Large double.positive_infinity
Negative Infinity Large double.negative_infinity
NaN Double.NaN
In the Java language, unlike the C + + language, all basic data types have presets, meaning that when we declare a variable, even if we do not assign a value to it, its value is certain, not as unpredictable as it would be in C + + +. The preset values for the specific types are shown in the following table:
Basic data type preset values
Boolean false
Char \u000
BYTE (byte) 0
Short (short) 0
Int 0
Long 0L
Float 0.0L
Double 0.0d
JAVA Data types