Java Data types

Source: Internet
Author: User

//Eight basic data types in Java, one reference data type string, remember to use double quotes//Although in Java, integers do not have any adornments, the default is an int constant, and the floating-point number does not have any adornments that represent a double type constant//However, the following direct assignment is not a problem, because when the Java compiler compiles, will determine whether the current constant is in the range of data type variables, if so, do not error//when computing data types in Java, the default is to convert to int, and when there are larger than int type, a long is converted to a large data type, and floating-point is converted to double//in Java, the conversion of data types, small data types to large data types, is automatically converted. While large data types are converted to small errors, the accuracy is lost. To cast//In a cast, is a bitwise conversion, int i = n; byte B = (byte) i; //-128, directly take the position, not only the maximum is 127, save 128 is the 127//The stored values in the computer are binary complementary forms of storage, positive number of the original code, anti-code, complement the same//Negative Inverse code: the original code based on the symbol bit unchanged, the remaining bits 0 for 1, 1 for 0. //negative complement: On the basis of the inverse code +1//so through the complement can be anti-roll out the original code, so you can calculate the number beyond the data type, not only can save 127, you save 128 will be 127

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.