8 Basic types of Java

Source: Internet
Author: User

The Java language provides eight basic types: six numeric types (four integers, two floating-point types), a character type, and a Boolean type.

Basic type Meaning Number of occupied digits Range of desirable values Default value
Byte BYTE type 8bit [-128,127] 0
Short Short-integer data 16bit [ -65526,65525] 0
Int Integral type data 32bit [ -2147483648,2147483647] 0
Long Long-integer data 64bit [ -9223372036854775808,9223372036854775807] 0
Float Single-precision floating-point number 32bit 0.0f
Double Double-precision floating-point number 64bit 0.0d
Char 16-bit Unicode characters 16bit [0,65525]
Boolean Boolean type Not clear True;false False

Note the point:

(1) The integer data base type (Byte/short/int/long) in 4 is an integer represented by a signed, twos complement, so assuming that the number of bits is nbit, the range is [ -2^n,2^n-1];

(2) Floating-point numbers cannot be used to accurately represent a specific value

For more information on the basic types, refer to: http://www.runoob.com/java/java-basic-datatypes.html

For a Boolean occupancy, refer to: https://www.jianshu.com/p/2f663dc820d0

8 Basic types of Java

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.