-- Start
Java has eight basic data types (primitive type), four integer types, two floating point types, one primitive type, and one boolean type.
Each data type corresponds to a packaging class, which can be automatically converted between them after JDK 1.5.Automatic PackingAndAutomatic unpacking. It is worth noting that they are all final classes, so we cannot inherit them to implement their own subclass.
All packaging classes provide the valueof method and constructor method to create their instances. If possible, we should try to use the valueof method, because they provide cache to save space and improve performance.
If you do not know the UTF-16 encoding, you cannot understand the methods provided by the character class. fortunately, char is rarely used unless recommended. It is too low-level. We recommend that you use string whenever possible. but as a good programmer, it is very necessary to understand some UTF-16 coding, I will give you a brief introduction to UTF-16 in the next section.
It is worth noting that Java also provides two classes that represent large numbers.BigintegerAndBigdecimal. They provide any precision. To perform mathematical operations on them, you must call the methods they provide instead of operators. The addition, subtraction, multiplication, division, and subtract methods are respectively added, subtract, divide, and multiply.
| Basic Type |
Packaging |
Storage Requirements |
| Byte |
Byte |
1 byte |
| Short |
Short |
2 bytes |
| Int |
Integer |
4 bytes |
| Long |
Long |
8 bytes |
| Float |
Float |
4 bytes |
| Double |
Double |
8 bytes |
| Char |
Character |
2 bytes |
| Boolean |
Boolean |
|
---For more information, see:Java
--Shengming: reprinted, please indicate the source
-- Last updated on 2012-06-12
-- Written by shangbo on 2012-04-24
-- End