Java automatic conversion

Source: Internet
Author: User

Java automatic conversion:

If both of the following conditions are met, when one type of data is assigned to another type of variable

Automatic type conversion ):

1.

these two types are compatible.

2.

the range of the destination type is greater than that of the source type.

when both of the preceding conditions are met, the widening conversion occurs. For example: the range of int type is greater than that of

the valid range of byte type is not required to display the forced type conversion statement.

for extended conversions, numeric types, including integer and floating point) the types are compatible with each other.

however, the numeric and character types (char) or Boolean) is incompatible. character type (char) and Boolean

type (Boolean) they are also incompatible.

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.