7) Java data type, java Data Type

Source: Internet
Author: User

7) Java data type, java Data Type

Data Types in Java are classified into basic data types and reference data types: 1) Basic data types include:Boolean, byte, short, char, int, float, long, double. They can be divided into four types: integer, floating point, char, and boolean. Byte, boolean: 1 short, char: 2 int, float: 4 long, double: 8 all basic data types have corresponding data encapsulation types.
Integer: byte, short, int, and long occupy 1, 2, 4, and 8 bytes respectively;
Integer type
Byte (byte type) one byte eight bits, occupies 1 byte. For example, 32B is 0 by default.
The value range is-2 (7-2 (7-1-128 ~ 127
Short (short integer) is a short 16-bit, which occupies 2 bytes. For example, 32 S, the default value is 0.
The value range is-2 (15-2 (15-1-32768 ~ 32767
Int (integer) is an int 32-bit, which occupies 4 bytes. For example 32, the default value is 0.
The value range is-2 (31-2 (31-1-2147483648 ~ 2147483647
Long (long integer) a long 64-bit occupies 8 bytes. For example, 32L is 0 by default.
The value range is-2 (63-2 (63-1-9223372036854774808 ~ 9223372036854774807
Float: long and float occupy 4 and 8 bytes respectively. char occupies 2 bytes and the encoding method is Unicode. The value range is/u0000 ~ /UFFFF; boolean type: boolean occupies 1 byte.
Automatic conversion of data types: (byte, short, char), int, long, float, and double (converted to the corresponding ASCII code value when the char type is converted to an integer) byte, short and char are of the same level, so they cannot be automatically converted to each other. You can use forced type conversion. Conversion between string type and other data types:
String-"Other: String. valueof (...) Other-" String:
     Integer.parseInt("66891")
     int i = Integer.valueOf("66891").intValue();
  2) Reference Data Type(Class, interface, array)

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.