8 basic data types in Java

Source: Internet
Author: User
Tags wrapper

There are eight basic types of Java, the basic types can be divided into three categories, character type char, Boolean and numeric type Byte, short, int, long, float, double. Numeric types can also be divided into integer type Byte, short, int, long, and floating-point type float, double. Numeric types in Java do not have unsigned, and their range of values is fixed and will not change as the machine hardware environment or operating system changes. In fact, there is another basic type Void in Java, which also has the corresponding wrapper class java.lang.Void, but we can't manipulate them directly. The types in 8 indicate the scope as follows:

Byte:8 bit, the maximum amount of storage data is 255, the range of data stored is between -128~127.

Short:16 bit, the maximum data storage is 65536, the data range is between -32768~32767.

Int:32 bit, the maximum data storage capacity is 2 of 32 times minus 1, the data range is negative 2 31 times to positive 2 of 31 times minus 1.

Long:64 bit, the maximum data storage capacity is 2 of 64 times minus 1, the data range is negative 2 63 times to positive 2 of 63 times minus 1.

Float:32 bit, the data range is 3.4e-45~1.4e38, the direct assignment must be followed by the number F or F.

Double:64 bit, the range of data in 4.9e-324~1.8e308, the value can be added D or D can not add.

Boolean: Only True and false two values.

Char:16 bits, stores Unicode codes, and assigns values in single quotes.

Java determines the size of each of the simple types. These sizes do not change as the structure of the machine changes. This immutable size is one of the reasons why Java programs have a strong ability to migrate. The following table lists the simple types defined in Java, the number of bits consumed, and the corresponding wrapper classes.

Simple Type

Boolean

Byte

Char

Short

Int

Long

Float

Double

void

Number of binary digits

1

8

16

16

32

64

32

64

--

Wrapper class

Boolean

Byte

Character

Short

Integer

Long

Float

Double

Void






reproduced from: http://www.cnblogs.com/doit8791/archive/2012/05/25/2517448.html

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.