First, the Java Language Foundation (2) _ Type and operation--basic data type conversion

Source: Internet
Author: User

2018-04-11

Basic Data type Conversions

I. Data too large and overflow

  Overflow: Data exceeds critical range of data type

If the overflow occurs, the program does not do the data check range processing, there will be data turbulence (WEN) chaos

Second, the basic data type automatic conversion (implicit conversion)

  In eight basic types, Boolean is not a numeric type and does not participate in conversions;

generally byte, short, char Three do not convert to each other, but the byte, short, char directly into an int.

  Conversion rules:

    The space size of the respective type, (converted from small to large) look at the graph:

    

Consider different data types as containers of different capacities:

    

II. Basic Data type coercion (explicit conversion)

  

1 // assign a constant of type int directly to a variable of type byte 2          byte a = a; 3 // because the compiler found 125 in byte range, the underlying secretly converted the
View Code

Iv. automatic elevation of expression types

  

The string type and any type of data are concatenated using "+", and the result is a string (string) type.

First, the Java Language Foundation (2) _ Type and operation--basic data type conversion

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.