Basic Java data types

Source: Internet
Author: User

integral type: Basic data type in Java byte, occupies 1 bytes, 8-bit range: 0000 0000 ~ 1111 1111 (-128 ~ 127) Why not: 0000 0000 ~ 1111 1111? In the actual programming language (a language), divided into signed, with unsigned, the highest bit is 1 o'clock negative, the highest bit is 0 the highest bit is the sign bit, the positive sign bit 0, the negative number is 1 1111 1111 represents the maximum of negative numbers:-1 negative binary = positive (absolute value of the number) binary inverse Code + 1. the largest positive number is 0 1111111, which is 2^0+2^1+......+2^6=127; the smallest negative number, the same as 1 1111111, or 127. There is a problem with the above description, that is 0, there will be a +0 and a-0. So the 0 is 128, which is the perfect combination of the complement of the computer (the program is perfectly set to run in the same order) . and so on, Int,short,long can launch their range of values.

Second, floating-point type:: Both float and double need to be marked separately. For example: float f = 123.45f;double d = 123.45D;

Three, character type: Char is a single character enclosed by single quotation marks, and is compatible with int. For example, make the following statement:

int a = ' a ';//a =97

char c =65;//c = ' A '

Four: Boolean (Logical): Boolean has only two states, which is "true" and "false".

Boolean t = True;//1 for true, logical true

T = false;//0 indicates false, logical false

Basic Java data types

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.