Basic data types in Java

Source: Internet
Author: User

In data types, the most common and basic data types are called basic data types. You can use these types of values to represent some simple states.

There are 8 basic data types for the Java language, the following are the 4 categories that are divided by purpose:

Fixed-point type:
An integral type is a class of types that represent integer values. When you need to represent a value for an integer, you can choose from 4 types as needed, and if there is no special requirement, the int type is generally selected. 4 types of integers differ mainly in the amount of space each data occupies in memory and the range of values represented.

Floating-point types:
A decimal type is a class of types that represent small values. When you need to represent a decimal value, you can pick the appropriate one from the following 2 types as needed. If there is no special requirement, the double type is generally selected .
Because decimals are stored in different ways than integers, decimals have a certain precision, so they are not accurate in computing. Two types of decimals are designed according to the difference between precision and storage interval.

Character type:
The character type represents a specific character, as described earlier, the computer is in the form of character sets to save characters, so the value of the character type is actually just the number in the character set, rather than the actual character represented by the computer to complete the work of converting from number to corresponding character. for more convenient internationalization in the Java language, the Unicode character set is used as the default character set, which contains characters that are common in various languages. In program code, characters use a pair of single quotes plus characters that need to be expressed to identify, for example
such as 'a ', 'a ' and so on, of course, can also directly use the character encoding, that is, a non-negative integer to represent.

Boolean type:
Boolean represents the formation and the non-establishment of logic. The use of the keyword true in the Java language means that thefalse representative is not valid. Boolean is the type of stored logical values, in fact, many programs have the concept of logical values, Java to thelogical value of the Boolean type to express.

Basic data types in Java

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.