Learning Diary (c) Java data types

Source: Internet
Author: User

Java is a strongly typed language, so-called strongly typed, which means that each variable must have a definite type, and each expression must have an explicit type, including some parameters passed. There are two big data types in Java, namely the basic data type and the reference data type, the basic data type is eight in Java, and the reference data type is all types except eight, which are generally customized as needed in the program.

The basic data types include shaping int, byte-shaped byte, short, long, char, float, double decimal, and Boolean, and the words for these types are defined by Java, A code-only, just remember, just like to call people, and pig called pigs, if the original reverse, then now is a code is not the same, the human nature will not change.

Integral type, as the name implies is the integer type, all the positive and negative integers and 0, but in fact, is not the case, the integer type is only the most commonly used, byte type, short integer, Long integer type is also integer, the four reason is different, because their storage range size is different, the number of bytes of the difference. From byte, short to int, long, occupy 1, 2, 4, 8 bytes, in the computer is 8, 16, 32, 64 bits, because the computer internal storage is complete 0 and 1, each one is a 0 or 1, each eight 0 and 1 is a byte combination. These four types of storage range usually need to remember that byte is 128 to 127 of the number, int is the most commonly used, can store negative more than 2 billion to positive more than 2 billion of the integer, and long can almost store we can usually use a large enough number.

Numbers often deal with operations, "+ 、-、 *,/" These symbols also need to be stored, commonly used in char-type chars storage, but Char can also be used to store some special characters. It accounts for 2 bytes.

In addition to integers, in addition to decimals or floating-point numbers, in Java is the float and double type, we commonly use double, which accounts for 8 bytes, and float occupies 4 bytes.

The last basic type is Boolean, which has only two values, true and false, right or wrong, yes or no, true or false.

Basic data types can be declared directly without new. At the same time, there is a special type of reference string, the string type, which can be declared directly as a basic data type without new, because it is very common.

At any time, the integer expression contains the byte, short before the operation, the type is promoted to integer recalculation.


Learning Diary (c) 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.