7) Java data type

Source: Internet
Author: User

Data types in Java are divided intoBasic data TypesAndReference Data Type: 1) The underlying data types are:Boolean, Byte, short, char, int, float, long, double.      They can be divided into four types, integer, float, 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, long occupy 1, 2, 4, 8 bytes of space respectively;
integer Type
byte
(byte type) A byte 8 bit, occupies 1 byte example 32B default is 0
The value range is -2 (7-2 (7-1 -128~127
short 16 bit, 2 byte case 32S default is 0.
The value range is -2 (15-2 (15-1 -32768~32767
int (integer) an int 32 bits, takes 4 byte example 32 default is 0
The value range is -2 (31-2 (31-1 -2147483648~2147483647
Long
(length integer) A long 64 bit takes 8 byte example 32L default is 0
The value range is -2 (63-2 (63-1 -9223372036854774808~9223372036854774807
float: Long, float occupies 4, 8 bytes respectively, Char: Char occupies 2 bytes, encoding is Unicode, the value range is/u0000~/uffff;boolean type: Boolean occupies 1 bytes.
Automatic conversion of data type: (Byte,short,char), int,long,float,double (char converted to integer, converted to corresponding ASCII code value)Byte,short,char Three types, they are lateral and therefore cannot be converted automatically to each other and can be cast using coercion. Conversion of string type to 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)

7) Java data type

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.