"Java" data type

Source: Internet
Author: User

Logical Type Boolean:

Boolean data can only take a value of true or FALSE, not 0 or 0 instead of true or false, which differs from the C language.

Character Char:

A char-type character occupies two bytes. To express by means of ' ', as ' A '

Integer type (byte, short, int, long):

Byte occupies 1 bytes, from 128 to 127
Short takes 2 bytes, from 32768 to 32767 (about 30,000)
int from 4 bytes,-2147483648, to 2147483647 total 10 bits, general integers by default int type.
Long takes 8 bytes, from 9223372036854775808 to 9223372036854775807 total 19 bits

Floating-point type (float, double):

Java float type defaults to double, if you declare a float variable, you need to add f after the data, such as float fl=3.22f.

Look at the following code:

BYTE by=4by=by+3

This compiles an error because the integer 3 defaults to int, and the int and byte types do not operate on each other. The following modifications can be made

The byte by=4by= (byte) (by+3)//by automatically changes from a byte byte to a four-byte int, and after the operation is completed, a byte cast

  

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