JAVA 1.2 (Native datatype Primitive data type)

Source: Internet
Author: User

1. Java data types are divided into 2 categories

>> Native datatype (primitive data type)

>> reference data type (reference)

3. Constants and variables

Constant: The so-called constant is the amount of value that does not change;

Variable is the amount of value that can change.

4. How do I define and use variables?

int A; Declaration of variables

A = 10; Initialization of variables

int B = 20; Declaration and initialization of variables

Note: If no initialization results in the following:

The difference between = = and = in Java:

= Represents an assignment operation, assigning the value to the right of the equal sign to the left variable

= = equals

format:
The name of the variable's type variable = value;

5. There are 4 types of native data types 8

>> integer type int denotes an int representing 32-bit 2^32 (-2147483648-2147483647)

>> character type Byte represents a character type 8 bits (-128-127)

>> Short integer 16 bits (-32768-32767) 65535

>> Long Integer is 64 bits, he is the largest representation range for shaping

6. Literal and Direct volume

7. Java Each data type is a range, if you exceed this range, then will form a closed loop, such as your maximum value plus 1 So the result is the minimum value, the minimum value minus 1 results is the maximum value

8. In Java, an integer by default is of type int, and if you are assigning an int type to a byte type the system will think of losing precision and running out of compile error. If you have to assign a value like this, then you need to manually force the type conversion

JAVA 1.2 (Native datatype Primitive 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.