Java Data Type

Source: Internet
Author: User

-- 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.