Java Basic Road (i)

Source: Internet
Author: User

Java data types are divided into built-in types and extension types, where the built-in type is the base data type, and the extension type is the other type (also called the reference type) that the Java language extends out of the base type (for example, class,string, and so on). This paper mainly discusses the former.

Boolean: Can only fetch two values: True and false, used to determine whether;

Byte,short,int,long: All represent integer types, but the respective range of values is different from the size of the occupied space, and the larger the range, the greater the space occupied. Generally used int type, but if the memory consumption requirements are relatively strict, you should carefully choose which type to use;

float and double: denotes floating-point type, that is, decimal, value range and occupy space with the same integer type, occupy more space, decimal precision is higher;

Type conversions:

In programming, sometimes we need to convert one type to another, and this process is called type conversion. The transition from a type with a low precision to a type with high precision can be directly converted, for example:

int a = 10;

Long B = A;

Going from a type with a high precision to a type with a low precision requires coercion of type conversions, like this:

Long T = 7878787;

int b = (int) T;

Finish.

Java Basic Road (i)

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.